Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove in_environment from test/test_rake_task_argument_parsing.rb

Fix file utils tests
  • Loading branch information...
commit a119d1b8b95ebc2115d66e59b35cd430016ba35a 1 parent 98e8772
@drbrain drbrain authored
View
21 test/helper.rb
@@ -24,7 +24,12 @@ def setup
ARGV.clear
@orig_PWD = Dir.pwd
- @orig_RAKE_SYSTEM = ENV['RAKE_SYSTEM']
+ @orig_RAKE_COLUMNS = ENV['RAKE_COLUMNS']
+ @orig_RAKE_SYSTEM = ENV['RAKE_SYSTEM']
+ @orig_RAKEOPT = ENV['RAKEOPT']
+ ENV.delete 'RAKE_COLUMNS'
+ ENV.delete 'RAKE_SYSTEM'
+ ENV.delete 'RAKEOPT'
tmpdir = Dir.chdir Dir.tmpdir do Dir.pwd end
@tempdir = File.join tmpdir, "test_rake_#{$$}"
@@ -38,11 +43,23 @@ def teardown
Dir.chdir @orig_PWD
FileUtils.rm_rf @tempdir
+ if @orig_RAKE_COLUMNS then
+ ENV['RAKE_COLUMNS'] = @orig_RAKE_COLUMNS
+ else
+ ENV.delete 'RAKE_COLUMNS'
+ end
+
if @orig_RAKE_SYSTEM then
ENV['RAKE_SYSTEM'] = @orig_RAKE_SYSTEM
else
ENV.delete 'RAKE_SYSTEM'
end
+
+ if @orig_RAKEOPT then
+ ENV['RAKEOPT'] = @orig_RAKEOPT
+ else
+ ENV.delete 'RAKEOPT'
+ end
end
def ignore_deprecations
@@ -52,7 +69,7 @@ def ignore_deprecations
Rake.application.options.ignore_deprecate = false
end
- def rake_system
+ def rake_system_dir
@system_dir = File.join @tempdir, 'system'
FileUtils.mkdir_p @system_dir
View
2  test/test_rake_application.rb
@@ -219,7 +219,7 @@ def test_load_rakefile_not_found
end
def test_load_from_system_rakefile
- rake_system
+ rake_system_dir
@app.instance_eval do
handle_options
View
58 test/test_rake_task_argument_parsing.rb
@@ -45,20 +45,20 @@ def test_keeps_embedded_spaces
def test_terminal_width_using_env
app = Rake::Application.new
- in_environment('RAKE_COLUMNS' => '1234') do
- assert_equal 1234, app.terminal_width
- end
+ app.terminal_columns = 1234
+
+ assert_equal 1234, app.terminal_width
end
def test_terminal_width_using_stty
app = Rake::Application.new
+
flexmock(app,
:unix? => true,
:dynamic_width_stty => 1235,
:dynamic_width_tput => 0)
- in_environment('RAKE_COLUMNS' => nil) do
- assert_equal 1235, app.terminal_width
- end
+
+ assert_equal 1235, app.terminal_width
end
def test_terminal_width_using_tput
@@ -67,50 +67,44 @@ def test_terminal_width_using_tput
:unix? => true,
:dynamic_width_stty => 0,
:dynamic_width_tput => 1236)
- in_environment('RAKE_COLUMNS' => nil) do
- assert_equal 1236, app.terminal_width
- end
+
+ assert_equal 1236, app.terminal_width
end
def test_terminal_width_using_hardcoded_80
app = Rake::Application.new
flexmock(app, :unix? => false)
- in_environment('RAKE_COLUMNS' => nil) do
- assert_equal 80, app.terminal_width
- end
+
+ assert_equal 80, app.terminal_width
end
def test_terminal_width_with_failure
app = Rake::Application.new
flexmock(app).should_receive(:unix?).and_throw(RuntimeError)
- in_environment('RAKE_COLUMNS' => nil) do
- assert_equal 80, app.terminal_width
- end
+
+ assert_equal 80, app.terminal_width
end
def test_no_rakeopt
- in_environment do
- ARGV << '--trace'
- app = Rake::Application.new
- app.init
- assert !app.options.silent
- end
+ ARGV << '--trace'
+ app = Rake::Application.new
+ app.init
+ assert !app.options.silent
end
def test_rakeopt_with_blank_options
- in_environment("RAKEOPT" => "") do
- ARGV << '--trace'
- app = Rake::Application.new
- app.init
- assert !app.options.silent
- end
+ ARGV << '--trace'
+ app = Rake::Application.new
+ app.init
+ assert !app.options.silent
end
def test_rakeopt_with_silent_options
- in_environment("RAKEOPT" => "-s") do
- app = Rake::Application.new
- app.init
- assert app.options.silent
- end
+ ENV['RAKEOPT'] = '-s'
+ app = Rake::Application.new
+
+ app.init
+
+ assert app.options.silent
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.