Permalink
Browse files

Added a feature demonstrating/documentation usage of shared example g…

…roups.

Closes #68.
  • Loading branch information...
myronmarston authored and dchelimsky committed Jul 12, 2010
1 parent 328f7e7 commit cbd5a8a26885106e0483d189e9d39d80d58f7f77
Showing with 35 additions and 0 deletions.
  1. +35 −0 features/example_groups/shared_example_group.feature
@@ -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.