Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Unknown
-
Resolution: Fixed
-
Affects Version/s: 10.14.0
-
Fix Version/s: 10.14.0
-
Component/s: Chef Client
-
Labels:None
Description
This example illustrates how we can use rpsec metadata to exclude tests:
Spec.configure do |c| c.filter_run_excluding :broken => true end describe "group 1" do before(:all) { puts "before all in included group" } after(:all) { puts "after all in included group" } it "group 1 example" do end end describe "group 2", :broken => true do before(:all) { puts "before all in excluded group" } after(:all) { puts "after all in excluded group" } context "context 1" do it "group 2 context 1 example 1" do end end end
This produces the following output:
$ rspec -cbfs spec
Run options: exclude {:broken=>true}
group 1
before all in included group
group 1 example
after all in included group
Finished in 0.00409 seconds
1 example, 0 failures
However, if the metadata is set inside a shared group, it appears to be out of context:
RSpec.configure do |c| c.filter_run_excluding :broken => true end shared_context "group 2", :broken => true do before(:all) { puts "before all in excluded group" } after(:all) { puts "after all in excluded group" } context "context 1" do it "group 2 context 1 example 1" do end end end describe "group 1" do include_context "group 2" before(:all) { puts "before all in included group" } after(:all) { puts "after all in included group" } it "group 1 example" do end end
rspec -cbfs spec
Run options: exclude {:broken=>true}
group 1
before all in excluded group
before all in included group
group 1 example
context 1
group 2 context 1 example 1
after all in included group
after all in excluded group
Finished in 0.00484 seconds
2 examples, 0 failures
Activity
- All
- Comments
- History
- Activity
- Transitions Summary
Fixed in 65d5c84.
Refactored shared_examples to add additional levels of context and put the metadata on those rather than on the before lines. I'm still not sure if before supports metadata in rspec, but I believe this structure is cleaner anyway.