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

Commit ce01d93

Browse files
committed
Support windows shell variables in isolation test
1 parent ed6cd8c commit ce01d93

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

spec/rspec/core/rake_task_spec.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,17 @@ def silence_output(&block)
151151
context "with_clean_environment is set" do
152152
it "removes the environment variables", :if => RUBY_VERSION >= '1.9.0', :unless => RSpec::Support::Ruby.jruby? do
153153
with_env_vars 'MY_ENV' => 'ABC' do
154+
if RSpec::Support::OS.windows?
155+
essential_shell_variables = "[\"ANSICON\", \"ANSICON_DEF\", \"HOME\", \"TMPDIR\", \"USER\"]"
156+
else
157+
essential_shell_variables = /\["PWD"(?:, "SHLVL")?(?:, "_")?(?:, "__CF_USER_TEXT_ENCODING")?\]/
158+
end
159+
154160
expect {
155161
task.with_clean_environment = true
156162
task.ruby_opts = '-e "puts \"Environment: #{ENV.keys}\""'
157163
task.run_task false
158-
}.to avoid_outputting.to_stderr.and output(
159-
/\["PWD"(?:, "SHLVL")?(?:, "_")?(?:, "__CF_USER_TEXT_ENCODING")?\]/
160-
).to_stdout_from_any_process
164+
}.to avoid_outputting.to_stderr.and output(essential_shell_variables).to_stdout_from_any_process
161165
end
162166
end
163167
end

0 commit comments

Comments
 (0)