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

Commit e83af48

Browse files
committed
Exclude running rake task in a clean environment on 1.8.7 or JRuby
1 parent 0e3e8ed commit e83af48

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lib/rspec/core/rake_task.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,20 @@ class RakeTask < ::Rake::TaskLib
4545
# A message to print to stderr when there are failures.
4646
attr_accessor :failure_message
4747

48-
# Run RSpec with a clean (empty) environment.
49-
attr_accessor :with_clean_environment
48+
if RUBY_VERSION < "1.9.0" || Support::Ruby.jruby?
49+
# Run RSpec with a clean (empty) environment is not supported
50+
def with_clean_environment=(_value)
51+
raise ArgumentError, "Running in a clean environment is not supported on Ruby versions before 1.9.0"
52+
end
53+
54+
# Run RSpec with a clean (empty) environment is not supported
55+
def with_clean_environment
56+
false
57+
end
58+
else
59+
# Run RSpec with a clean (empty) environment.
60+
attr_accessor :with_clean_environment
61+
end
5062

5163
# Use verbose output. If this is set to true, the task will print the
5264
# executed spec command to stdout. Defaults to `true`.

spec/rspec/core/rake_task_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def silence_output(&block)
149149
end
150150

151151
context "with_clean_environment is set" do
152-
it "removes the environment variables" do
152+
it "removes the environment variables", :if => (RUBY_VERSION >= '1.9.0' || RSpec::Support::Ruby.jruby?) do
153153
with_env_vars 'MY_ENV' => 'ABC' do
154154
expect {
155155
task.with_clean_environment = true

0 commit comments

Comments
 (0)