| 1 |
Feature: `--init` option |
| 2 |
|
| 3 |
Use the `--init` option on the command line to generate conventional files for |
| 4 |
an RSpec project. It generates a `.rspec` and `spec/spec_helper.rb` with some |
| 5 |
example settings to get you started. |
| 6 |
|
| 7 |
These settings treat the case where you run an individual spec file |
| 8 |
differently, using the documentation formatter if no formatter has been |
| 9 |
explicitly set. |
| 10 |
|
| 11 |
Scenario: Generate `.rspec` |
| 12 |
When I run `rspec --init` |
| 13 |
Then the file `.rspec` should exist |
| 14 |
And the output should contain "create .rspec" |
| 15 |
|
| 16 |
Scenario: `.rspec` file already exists |
| 17 |
Given a file named ".rspec" with: |
| 18 |
""" |
| 19 |
--force-color |
| 20 |
""" |
| 21 |
When I run `rspec --init` |
| 22 |
Then the output should contain "exist .rspec" |
| 23 |
|
| 24 |
Scenario: Accept and use the recommended settings in `spec_helper` (which are initially commented out) |
| 25 |
Given I have a brand new project with no files |
| 26 |
And I have run `rspec --init` |
| 27 |
When I accept the recommended settings by removing `=begin` and `=end` from `spec_helper.rb` |
| 28 |
And I create "spec/addition_spec.rb" with the following content: |
| 29 |
"""ruby |
| 30 |
RSpec.describe "Addition" do |
| 31 |
it "works" do |
| 32 |
expect(1 + 1).to eq(2) |
| 33 |
end |
| 34 |
end |
| 35 |
""" |
| 36 |
And I create "spec/subtraction_spec.rb" with the following content: |
| 37 |
"""ruby |
| 38 |
RSpec.describe "Subtraction" do |
| 39 |
it "works" do |
| 40 |
expect(1 - 1).to eq(0) |
| 41 |
end |
| 42 |
end |
| 43 |
""" |
| 44 |
Then the output from `rspec` should not be in documentation format |
| 45 |
But the output from `rspec spec/addition_spec.rb` should be in documentation format |
| 46 |
But the output from `rspec spec/addition_spec.rb --format progress` should not be in documentation format |
| 47 |
|
| 48 |
And the output from `rspec --pattern 'spec/*ction_spec.rb'` should indicate it ran only the subtraction file |
| 49 |
And the output from `rspec --exclude-pattern 'spec/*dition_spec.rb'` should indicate it ran only the subtraction file |