This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cart < ActiveRecord::Base | |
has_many :items, :class_name => 'CartItem', :dependent => :destroy | |
# ... | |
def empty! | |
items.each(&:destroy) | |
self | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it 'should do something' do | |
on_failure warn_that "@foo shouldn't be nil" do | |
@foo.should_not be_nil | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bin/spec spec | |
....................................................................................................................................................................................................................................................................*....................................................*...........................................................................................................................................................................................................................................................................................................................................................*......................................................................................................................................................................................................................................................................................................................................................... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |