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

Commit d0f5900

Browse files
committed
Make specs global configuration proof
If a `~/.config/rspec/options` file contains the following: --color --profile 2 --format progress --require pry specs fail, since `--profile 2` option is picked up and used by the code under test. `$XDG_CONFIG_HOME/rspec/options` has to be isolated for some specs.
1 parent cb1b4ce commit d0f5900

File tree

6 files changed

+38
-8
lines changed

6 files changed

+38
-8
lines changed

spec/integration/spec_file_load_errors_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
EOS
8484
end
8585

86-
it 'nicely handles load-time errors in user spec files' do
86+
it 'nicely handles load-time errors in user spec files', isolated_home: true do
8787
write_file_formatted "1_spec.rb", "
8888
boom
8989

spec/integration/suite_hooks_errors_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def run_spec_expecting_non_zero(before_or_after)
4949
normalize_durations(last_cmd_stdout)
5050
end
5151

52-
it 'nicely formats errors in `before(:suite)` hooks and exits with non-zero' do
52+
it 'nicely formats errors in `before(:suite)` hooks and exits with non-zero', isolated_home: true do
5353
output = run_spec_expecting_non_zero(:before)
5454
expect(output).to eq unindent(<<-EOS)
5555
@@ -67,7 +67,7 @@ def run_spec_expecting_non_zero(before_or_after)
6767
EOS
6868
end
6969

70-
it 'nicely formats errors in `after(:suite)` hooks and exits with non-zero' do
70+
it 'nicely formats errors in `after(:suite)` hooks and exits with non-zero', isolated_home: true do
7171
output = run_spec_expecting_non_zero(:after)
7272
expect(output).to eq unindent(<<-EOS)
7373
.
@@ -85,7 +85,7 @@ def run_spec_expecting_non_zero(before_or_after)
8585
EOS
8686
end
8787

88-
it 'nicely formats errors from multiple :suite hooks of both types and exits with non-zero' do
88+
it 'nicely formats errors from multiple :suite hooks of both types and exits with non-zero', isolated_home: true do
8989
write_file "the_spec.rb", "
9090
RSpec.configure do |c|
9191
c.before(:suite) { raise 'before 1' }

spec/rspec/core/formatters/documentation_formatter_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def execution_result(values)
100100
end
101101

102102
# The backtrace is slightly different on JRuby/Rubinius so we skip there.
103-
it 'produces the expected full output', :if => RSpec::Support::Ruby.mri? do
103+
it 'produces the expected full output', isolated_home: true, :if => RSpec::Support::Ruby.mri? do
104104
output = run_example_specs_with_formatter("doc")
105105
output.gsub!(/ +$/, '') # strip trailing whitespace
106106

spec/rspec/core/formatters/html_formatter_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ def extract_backtrace_from(doc)
5757
end
5858
end
5959

60-
describe 'produced HTML', :slow, :if => RUBY_VERSION >= '2.0.0' do
61-
it "is identical to the one we designed manually", :pending => (defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby') do
60+
describe 'produced HTML', :slow, isolated_home: true, :if => RUBY_VERSION >= '2.0.0' do
61+
it 'is identical to the one we designed manually', :pending => (defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby') do
6262
expect(actual_html).to eq(expected_html)
6363
end
6464

spec/rspec/core/formatters/progress_formatter_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
end
4141

4242
# The backtrace is slightly different on JRuby/Rubinius so we skip there.
43-
it 'produces the expected full output', :if => RSpec::Support::Ruby.mri? do
43+
it 'produces the expected full output', isolated_home: true, :if => RSpec::Support::Ruby.mri? do
4444
output = run_example_specs_with_formatter("progress")
4545
output.gsub!(/ +$/, '') # strip trailing whitespace
4646

spec/support/formatter_support.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ def expected_summary_output_for_example_specs
6969
| # ./spec/rspec/core/resources/formatter_specs.rb:18
7070
| # ./spec/support/formatter_support.rb:41:in `run_rspec_with_formatter'
7171
| # ./spec/support/formatter_support.rb:3:in `run_example_specs_with_formatter'
72+
| # ./spec/support/isolated_home_directory.rb:13:in `block (5 levels) in <top (required)>'
73+
| # ./spec/spec_helper.rb:46:in `with_env_vars'
74+
| # ./spec/support/isolated_home_directory.rb:12:in `block (4 levels) in <top (required)>'
75+
| # ./spec/spec_helper.rb:57:in `without_env_vars'
76+
| # ./spec/support/isolated_home_directory.rb:11:in `block (3 levels) in <top (required)>'
77+
| # ./spec/support/isolated_home_directory.rb:7:in `block (2 levels) in <top (required)>'
7278
| # ./spec/support/sandboxing.rb:16
7379
| # ./spec/support/sandboxing.rb:7
7480
|
@@ -89,6 +95,12 @@ def expected_summary_output_for_example_specs
8995
| # ./spec/rspec/core/resources/formatter_specs.rb:37
9096
| # ./spec/support/formatter_support.rb:41:in `run_rspec_with_formatter'
9197
| # ./spec/support/formatter_support.rb:3:in `run_example_specs_with_formatter'
98+
| # ./spec/support/isolated_home_directory.rb:13:in `block (5 levels) in <top (required)>'
99+
| # ./spec/spec_helper.rb:46:in `with_env_vars'
100+
| # ./spec/support/isolated_home_directory.rb:12:in `block (4 levels) in <top (required)>'
101+
| # ./spec/spec_helper.rb:57:in `without_env_vars'
102+
| # ./spec/support/isolated_home_directory.rb:11:in `block (3 levels) in <top (required)>'
103+
| # ./spec/support/isolated_home_directory.rb:7:in `block (2 levels) in <top (required)>'
92104
| # ./spec/support/sandboxing.rb:16
93105
| # ./spec/support/sandboxing.rb:7
94106
|
@@ -164,6 +176,12 @@ def expected_summary_output_for_example_specs
164176
| # ./spec/rspec/core/resources/formatter_specs.rb:18:in `block (3 levels) in <top (required)>'
165177
| # ./spec/support/formatter_support.rb:41:in `run_rspec_with_formatter'
166178
| # ./spec/support/formatter_support.rb:3:in `run_example_specs_with_formatter'
179+
| # ./spec/support/isolated_home_directory.rb:13:in `block (5 levels) in <top (required)>'
180+
| # ./spec/spec_helper.rb:46:in `with_env_vars'
181+
| # ./spec/support/isolated_home_directory.rb:12:in `block (4 levels) in <top (required)>'
182+
| # ./spec/spec_helper.rb:57:in `without_env_vars'
183+
| # ./spec/support/isolated_home_directory.rb:11:in `block (3 levels) in <top (required)>'
184+
| # ./spec/support/isolated_home_directory.rb:7:in `block (2 levels) in <top (required)>'
167185
| # ./spec/support/sandboxing.rb:16:in `block (3 levels) in <top (required)>'
168186
| # ./spec/support/sandboxing.rb:7:in `block (2 levels) in <top (required)>'
169187
|
@@ -184,6 +202,12 @@ def expected_summary_output_for_example_specs
184202
| # ./spec/rspec/core/resources/formatter_specs.rb:37:in `block (2 levels) in <top (required)>'
185203
| # ./spec/support/formatter_support.rb:41:in `run_rspec_with_formatter'
186204
| # ./spec/support/formatter_support.rb:3:in `run_example_specs_with_formatter'
205+
| # ./spec/support/isolated_home_directory.rb:13:in `block (5 levels) in <top (required)>'
206+
| # ./spec/spec_helper.rb:46:in `with_env_vars'
207+
| # ./spec/support/isolated_home_directory.rb:12:in `block (4 levels) in <top (required)>'
208+
| # ./spec/spec_helper.rb:57:in `without_env_vars'
209+
| # ./spec/support/isolated_home_directory.rb:11:in `block (3 levels) in <top (required)>'
210+
| # ./spec/support/isolated_home_directory.rb:7:in `block (2 levels) in <top (required)>'
187211
| # ./spec/support/sandboxing.rb:16:in `block (3 levels) in <top (required)>'
188212
| # ./spec/support/sandboxing.rb:7:in `block (2 levels) in <top (required)>'
189213
|
@@ -215,6 +239,12 @@ def expected_summary_output_for_example_specs
215239
| # ./spec/rspec/core/resources/formatter_specs.rb:50:in `block (2 levels) in <top (required)>'
216240
| # ./spec/support/formatter_support.rb:41:in `run_rspec_with_formatter'
217241
| # ./spec/support/formatter_support.rb:3:in `run_example_specs_with_formatter'
242+
| # ./spec/support/isolated_home_directory.rb:13:in `block (5 levels) in <top (required)>'
243+
| # ./spec/spec_helper.rb:46:in `with_env_vars'
244+
| # ./spec/support/isolated_home_directory.rb:12:in `block (4 levels) in <top (required)>'
245+
| # ./spec/spec_helper.rb:57:in `without_env_vars'
246+
| # ./spec/support/isolated_home_directory.rb:11:in `block (3 levels) in <top (required)>'
247+
| # ./spec/support/isolated_home_directory.rb:7:in `block (2 levels) in <top (required)>'
218248
| # ./spec/support/sandboxing.rb:16:in `block (3 levels) in <top (required)>'
219249
| # ./spec/support/sandboxing.rb:7:in `block (2 levels) in <top (required)>'
220250
|

0 commit comments

Comments
 (0)