Skip to content

Commit

Permalink
Added a feature demonstrating/documentation usage of shared example g…
Browse files Browse the repository at this point in the history
…roups.

Closes rspec#68.
  • Loading branch information
myronmarston authored and dchelimsky committed Jul 12, 2010
1 parent 328f7e7 commit cbd5a8a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions features/example_groups/shared_example_group.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Feature: Shared example group

As an RSpec user
I want to share my examples
In order to reduce duplication in my specs

Scenario: Using a shared example group
Given a file named "shared_example_group_spec.rb" with:
"""
require "set"
shared_examples_for "a collection object" do
before(:each) do
@instance = described_class.new([7, 2, 4])
end
it "should have 3 items" do
@instance.size.should == 3
end
it "should return the first item from #first" do
@instance.first.should == 7
end
end
describe Array do
it_should_behave_like "a collection object"
end
describe Set do
it_should_behave_like "a collection object"
end
"""
When I run "rspec ./shared_example_group_spec.rb"
Then the output should contain "4 examples, 0 failures"

0 comments on commit cbd5a8a

Please sign in to comment.