/
inclusion_filters.feature
106 lines (88 loc) · 3.15 KB
/
inclusion_filters.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
Feature: inclusion filters
You can restrict which examples are run by declaring an inclusion filter. The
most common use case is to focus on a subset of examples as you're focused on
a particular problem.
If you set the `treat_symbols_as_metadata_keys_with_true_values` config option
to `true`, you can specify metadata using only symbols.
Background:
Given a file named "spec/spec_helper.rb" with:
"""
RSpec.configure do |c|
# filter_run is short-form alias for filter_run_including
c.filter_run :focus => true
end
"""
Scenario: focus on an example
Given a file named "spec/sample_spec.rb" with:
"""
require "spec_helper"
describe "something" do
it "does one thing" do
end
it "does another thing", :focus => true do
end
end
"""
When I run `rspec spec/sample_spec.rb --format doc`
Then the output should contain "does another thing"
And the output should not contain "does one thing"
Scenario: focus on a group
Given a file named "spec/sample_spec.rb" with:
"""
require "spec_helper"
describe "group 1", :focus => true do
it "group 1 example 1" do
end
it "group 1 example 2" do
end
end
describe "group 2" do
it "group 2 example 1" do
end
end
"""
When I run `rspec spec/sample_spec.rb --format doc`
Then the output should contain "group 1 example 1"
And the output should contain "group 1 example 2"
And the output should not contain "group 2 example 1"
Scenario: before/after(:all) hooks in unmatched example group are not run
Given a file named "spec/before_after_all_inclusion_filter_spec.rb" with:
"""
require "spec_helper"
describe "group 1", :focus => true do
before(:all) { puts "before all in focused group" }
after(:all) { puts "after all in focused group" }
it "group 1 example" do
end
end
describe "group 2" do
before(:all) { puts "before all in unfocused group" }
after(:all) { puts "after all in unfocused group" }
context "context 1" do
it "group 2 context 1 example 1" do
end
end
end
"""
When I run `rspec ./spec/before_after_all_inclusion_filter_spec.rb`
Then the output should contain "before all in focused group"
And the output should contain "after all in focused group"
And the output should not contain "before all in unfocused group"
And the output should not contain "after all in unfocused group"
Scenario: Use symbols as metadata
Given a file named "symbols_as_metadata_spec.rb" with:
"""
RSpec.configure do |c|
c.treat_symbols_as_metadata_keys_with_true_values = true
c.filter_run :current_example
end
describe "something" do
it "does one thing" do
end
it "does another thing", :current_example do
end
end
"""
When I run `rspec symbols_as_metadata_spec.rb --format doc`
Then the output should contain "does another thing"
And the output should not contain "does one thing"