Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 99f9c28

Browse files
committed
Make features global configuration proof
If a `~/.config/rspec/options` file contains the following: --color --profile 2 --format progress a number of features fail, since options are picked up and used by the code under test. Resetting `XDG_CONFIG_HOME` for those features isolates the global configuration.
1 parent 5c26475 commit 99f9c28

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

features/command_line/init.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Feature: `--init` option
2525
Scenario: Accept and use the recommended settings in `spec_helper` (which are initially commented out)
2626
Given I have a brand new project with no files
2727
And I have run `rspec --init`
28+
And I unset XDG_CONFIG_HOME environment var
2829
When I accept the recommended settings by removing `=begin` and `=end` from `spec/spec_helper.rb`
2930
And I create "spec/addition_spec.rb" with the following content:
3031
"""ruby

features/command_line/warnings_option.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ Feature: `--warnings` option (run with warnings enabled)
2525
end
2626
end
2727
"""
28+
And I unset XDG_CONFIG_HOME environment var
2829
When I run `rspec example_spec.rb`
2930
Then the output should not contain "warning"

features/configuration/profile.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Feature: Profile examples
7373
"""
7474

7575
Scenario: By default does not show profile
76+
Given I unset XDG_CONFIG_HOME environment var
7677
When I run `rspec spec`
7778
Then the examples should all pass
7879
And the output should not contain "example 1"
@@ -92,6 +93,7 @@ Feature: Profile examples
9293
"""ruby
9394
RSpec.configure { |c| c.profile_examples = true }
9495
"""
96+
And I unset XDG_CONFIG_HOME environment var
9597
When I run `rspec spec`
9698
Then the examples should all pass
9799
And the output should contain "Top 10 slowest examples"

features/formatters/configurable_colors.feature

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ Feature: Configurable colors
2727
end
2828
end
2929
"""
30-
When I run `rspec custom_failure_color_spec.rb --format progress`
31-
Then the failing example is printed in magenta
30+
And I unset XDG_CONFIG_HOME environment var
31+
When I run `rspec custom_failure_color_spec.rb --format progress`
32+
Then the failing example is printed in magenta

features/step_definitions/additional_cli_steps.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@
238238
end
239239
end
240240

241+
Given(/^I unset XDG_CONFIG_HOME environment var$/) do
242+
step %q{I set the environment variables to:}, table(%{
243+
| variable | value |
244+
| XDG_CONFIG_HOME | |
245+
})
246+
end
247+
241248
module Normalization
242249
def normalize_failure_output(text)
243250
whitespace_normalized = text.lines.map { |line| line.sub(/\s+$/, '').sub(/:in .*$/, '') }.join

0 commit comments

Comments
 (0)