Logo: Relish

  1. Sign in

Project: RSpec Core 3.0

`--pattern` option

By default, RSpec loads files matching the pattern:

"spec/**/*_spec.rb"

Use the --pattern option to declare a different pattern.

Scenarios
Default pattern
Given
a file named "spec/example_spec.rb" with:
RSpec.describe "addition" do
  it "adds things" do
    expect(1 + 2).to eq(3)
  end
end
When
I run rspec
Then
the output should contain "1 example, 0 failures"
Override the default pattern on the command line
Given
a file named "spec/example.spec" with:
RSpec.describe "addition" do
  it "adds things" do
    expect(1 + 2).to eq(3)
  end
end
When
I run rspec --pattern "spec/**/*.spec"
Then
the output should contain "1 example, 0 failures"
Override the default pattern in configuration
Given
a file named "spec/spec_helper.rb" with:
  RSpec.configure do |config|
    config.pattern << ',**/*.spec'
  end
And
a file named "spec/example.spec" with:
RSpec.describe "addition" do
  it "adds things" do
    expect(1 + 2).to eq(3)
  end
end
When
I run rspec -rspec_helper
Then
the output should contain "1 example, 0 failures"

Last published about 4 years ago by myronmarston.