Skip to content

Commit

Permalink
example for filtering before(:all) etc with metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed Sep 19, 2013
1 parent 4c51980 commit 06da44c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions features/hooks/filtering.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,37 @@ Feature: filters
When I run `rspec filter_before_each_hooks_spec.rb`
Then the examples should all pass

Scenario: filter `before(:all)` hooks using arbitrary metadata
Given a file named "filter_before_all_hooks_spec.rb" with:
"""ruby
RSpec.configure do |config|
config.before(:all, :foo => :bar) do
@@invoked_hooks ||= []
@@invoked_hooks << :before_all_foo_bar
end
end
describe "a filtered before :all hook" do
describe "group without matching metadata" do
it "does not run the hook" do
expect(defined?(@@invoked_hooks)).to eq nil
end
it "runs the hook for an example with matching metadata", :foo => :bar do
@@invoked_hooks.should == [:before_all_foo_bar]
end
end
describe "group with matching metadata", :foo => :bar do
it "runs the hook" do
@@invoked_hooks.should == [:before_all_foo_bar]
end
end
end
"""
When I run `rspec filter_before_all_hooks_spec.rb`
Then the examples should all pass

Scenario: filter `after(:each)` hooks using arbitrary metadata
Given a file named "filter_after_each_hooks_spec.rb" with:
"""ruby
Expand Down

0 comments on commit 06da44c

Please sign in to comment.