Skip to content

Instantly share code, notes, and snippets.

View dchelimsky's full-sized avatar

David Chelimsky dchelimsky

  • Retired
  • Chicago, IL, USA
View GitHub Profile
# in config/environments/test.rb
config.gem "rspec", :lib => false, :version => "1.1.11"
# in a shell
$ rake gems:install
(in /Users/david/projects/ruby/tmp/foo)
Missing these required gems:
rspec = 1.1.11
Feature: login widget
Anonymous visitors see a login widget on every page
Logged in users see a welcome widget on every page
Scenario Outline:
Given I am <logged in or anonymous>
When I visit the <page>
Then I should see <widget>
module Matchers
class HaveNotice
def initialize(contents, scope)
@contents, @scope = contents, scope
end
def matches?(response)
response.should @scope.have_tag('div.notice', @contents)
end
class Cart < ActiveRecord::Base
has_many :items, :class_name => 'CartItem', :dependent => :destroy
# ...
def empty!
items.each(&:destroy)
self
end
Feature: code-breaker submits guess
The code-breaker submits a guess of four colored pegs. The mastermind game
marks the guess with black and white "marker" pegs.
For each peg in the guess that matches color and position of a peg in the
secret code, the mark includes one black peg. For each additional peg in the
guess that matches the color but not the position of a color in the guess, a
white peg is added to the mark.
it 'should do something' do
on_failure warn_that "@foo shouldn't be nil" do
@foo.should_not be_nil
end
end
$ bin/spec spec
....................................................................................................................................................................................................................................................................*....................................................*...........................................................................................................................................................................................................................................................................................................................................................*.........................................................................................................................................................................................................................................................................................................................................................
# Sets up the Merb environment for Cucumber (thanks to krzys and roman)
require "rubygems"
# Add the local gems dir if found within the app root; any dependencies loaded
# hereafter will try to load from the local gems before loading system gems.
if (local_gem_dir = File.join(File.dirname(__FILE__), '..', 'gems')) && $BUNDLE.nil?
$BUNDLE = true; Gem.clear_paths; Gem.path.unshift(local_gem_dir)
end
require "merb-core"
def given(name, &block)
$givens ||= {}
$givens[name] = block
end
Spec::Runner.configure do |c|
c.on_option :given do |group, value|
group.description += value
group.prepend_before $givens[value]
end
Feature: conditional exclusion of example groups
Example groups can be excluded from a run by matching the value of the
--exclude argument against options passed to an example group. The value
can be a key or a key:value pair (separated by a ":").
Scenario: exclusion using explicit value
Given the following spec:
"""
describe "This should run" do