Skip to content

Commit

Permalink
Skip testing default gems on rubies without them
Browse files Browse the repository at this point in the history
Ruby 1.9.3 and earlier do not have default gems but Rake tests tried to
use them leading to an error.

Now the test using default gems is skipped when default gems are not
present.

Fixes #8
  • Loading branch information
drbrain committed Dec 3, 2014
1 parent fa980b6 commit fbbfdad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions History.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Bug fixes:
task. Pull requset #9 by Matt Palmer.
* Documented how Rake::DSL#desc handles sentences in task descriptions.
Issue #7 by Raza Sayed.
* Fixed test error on 1.9.3 with legacy RubyGems. Issue #8 by Matt Palmer.
* Deleted duplicated History entry. Pull request #10 by Yuji Yamamoto.

=== 10.4.1 / 2014-12-01
Expand Down
19 changes: 12 additions & 7 deletions test/test_rake_test_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,22 @@ def test_run_code_rake
end

def test_run_code_rake_default_gem
skip 'this ruby does not have default gems' unless
Gem::Specification.method_defined? :default_specifications_dir

default_spec = Gem::Specification.new 'rake', 0
default_spec.loaded_from = File.join Gem::Specification.default_specifications_dir, 'rake-0.gemspec'
rake, Gem.loaded_specs['rake'] = Gem.loaded_specs['rake'], default_spec
begin
rake, Gem.loaded_specs['rake'] = Gem.loaded_specs['rake'], default_spec

test_task = Rake::TestTask.new do |t|
t.loader = :rake
end
test_task = Rake::TestTask.new do |t|
t.loader = :rake
end

assert_match(/\A(-I".*?" *)* ".*?"\Z/, test_task.run_code)
ensure
Gem.loaded_specs['rake'] = rake
assert_match(/\A(-I".*?" *)* ".*?"\Z/, test_task.run_code)
ensure
Gem.loaded_specs['rake'] = rake
end
end

def test_run_code_testrb_ruby_1_8_2
Expand Down

0 comments on commit fbbfdad

Please sign in to comment.