forked from rspec/rspec-core
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a feature demonstrating/documentation usage of shared example g…
…roups. Closes rspec#68.
- Loading branch information
1 parent
328f7e7
commit cbd5a8a
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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" |