Skip to content

Commit

Permalink
rewrite feature
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed May 15, 2013
1 parent f34ca7e commit a24ed4b
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions features/example_groups/shared_examples.feature
Expand Up @@ -220,39 +220,44 @@ Feature: shared examples
"""
1 example, 0 failures
"""
Scenario: Shared examples are specific to their context
Given a file named "context_specific_examples_spec.rb" with:
"""
describe do
context "my context" do
shared_examples "is independant" do
specify { expect(subject).to eq "context" }
end

subject { "context" }
Scenario: Shared examples are nested able by context
Given a file named "context_specific_examples_spec.rb" with:
"""Ruby
describe "shared examples" do
context "per context" do
it_should_behave_like "is independant"
end
context "another context" do
shared_examples "is independant" do
specify { expect(subject).to eq "another context" }
shared_examples "shared examples are nestable" do
specify { expect(true).to eq true }
end
subject { "another context" }
it_should_behave_like "is independant"
it_behaves_like "shared examples are nestable"
end
end
"""
When I run `rspec context_specific_examples_spec.rb`
Then the output should contain:
"""
1 example, 0 failures
"""

Scenario: Shared examples are isolated per context
Given a file named "isolated_shared_examples_spec.rb" with:
"""Ruby
describe "shared examples" do
context do
begin
it_should_behave_like "is independant"
fail "Shared examples should be dependant on context"
rescue ArgumentError
shared_examples "shared examples are isolated" do
specify { expect(true).to eq true }
end
end
context do
it_behaves_like "shared examples are isolated"
end
end
"""
When I run `rspec context_specific_examples_spec.rb`
When I run `rspec isolated_shared_examples_spec.rb`
Then the output should contain:
"""
2 examples, 0 failures
Could not find shared examples "shared examples are isolated"
"""

0 comments on commit a24ed4b

Please sign in to comment.