Debian Codegraph @

rspec-core/features/command_line/pattern_option.feature

raw
1 Feature: `--pattern` option
2
3 When you run RSpec without giving it specific file names, it determines which
4 files to load by applying a pattern to the provided directory arguments or
5 `spec` (if no directories are provided). By default, RSpec uses the following
6 pattern:
7
8 "**{,/*/**}/*_spec.rb"
9
10 Use the `--pattern` option to declare a different pattern.
11
12 Background:
13 Given a file named "spec/example_spec.rb" with:
14 """ruby
15 RSpec.describe "two specs" do
16 it "passes" do
17 end
18
19 it "passes too" do
20 end
21 end
22 """
23 And a file named "spec/example_test.rb" with:
24 """ruby
25 RSpec.describe "one spec" do
26 it "passes" do
27 end
28 end
29 """
30
31 Scenario: By default, RSpec runs matching spec files
32 When I run `rspec`
33 Then the output should contain "2 examples, 0 failures"
34
35 Scenario: The `--pattern` flag makes RSpec run files matching the specified pattern and ignore the default pattern
36 When I run `rspec -P "**/*_test.rb"`
37 Then the output should contain "1 example, 0 failures"
38
39 Scenario: The `--pattern` flag can be used to pass in multiple patterns, separated by commas
40 When I run `rspec -P "**/*_test.rb,**/*_spec.rb"`
41 Then the output should contain "3 examples, 0 failures"
42
43 Scenario: The `--pattern` flag accepts shell style glob unions
44 When I run `rspec -P "**/*_{test,spec}.rb"`
45 Then the output should contain "3 examples, 0 failures"