diff --git a/lib/shoulda/private_helpers.rb b/lib/shoulda/private_helpers.rb index e48d457f..0bde890f 100644 --- a/lib/shoulda/private_helpers.rb +++ b/lib/shoulda/private_helpers.rb @@ -7,7 +7,7 @@ module Shoulda # :nodoc: opts = (args.last.is_a?(Hash) ? args.pop : {}) wanted.each {|w| ret << opts.delete(w)} raise ArgumentError, "Unsupported options given: #{opts.keys.join(', ')}" unless opts.keys.empty? - return *ret + return wanted.size == 1 ? ret.first : ret end end end diff --git a/lib/shoulda/test_unit.rb b/lib/shoulda/test_unit.rb index 88bf35c4..0464c239 100644 --- a/lib/shoulda/test_unit.rb +++ b/lib/shoulda/test_unit.rb @@ -1,3 +1,5 @@ +require 'test/unit' + require 'shoulda/context' require 'shoulda/proc_extensions' require 'shoulda/assertions' diff --git a/test/fail_macros.rb b/test/fail_macros.rb index 408cdf13..b8b4d6d3 100644 --- a/test/fail_macros.rb +++ b/test/fail_macros.rb @@ -13,7 +13,12 @@ module Shoulda # end def should_fail(&block) context "should fail when trying to run:" do - Shoulda.expected_exceptions = [Test::Unit::AssertionFailedError] + if defined?(Test::Unit::AssertionFailedError) + failures = [Test::Unit::AssertionFailedError] + elsif defined?(MiniTest::Assertion) + failures = [MiniTest::Assertion] + end + Shoulda.expected_exceptions = failures yield block Shoulda.expected_exceptions = nil end diff --git a/test/other/private_helpers_test.rb b/test/other/private_helpers_test.rb index f5835997..7bfe6547 100644 --- a/test/other/private_helpers_test.rb +++ b/test/other/private_helpers_test.rb @@ -22,5 +22,11 @@ class PrivateHelpersTest < ActiveSupport::TestCase # :nodoc: get_options!(args, :one) end end + + should "return single wanted option" do + args = [:a, :b, {:class => Object}] + klass = get_options!(args,:class) + assert_equal Object, klass + end end end diff --git a/test/rails_root/config/boot.rb b/test/rails_root/config/boot.rb index cd21fb9e..0ad0f787 100644 --- a/test/rails_root/config/boot.rb +++ b/test/rails_root/config/boot.rb @@ -44,6 +44,7 @@ module Rails def load_initializer require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" Rails::Initializer.run(:install_gem_spec_stubs) + Rails::GemDependency.add_frozen_gem_path end end @@ -67,7 +68,7 @@ module Rails class << self def rubygems_version - Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion + Gem::RubyGemsVersion rescue nil end def gem_version @@ -82,14 +83,14 @@ module Rails def load_rubygems require 'rubygems' - - unless rubygems_version >= '0.9.4' - $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.) + min_version = '1.3.1' + unless rubygems_version >= min_version + $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.) exit 1 end rescue LoadError - $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org) + $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org) exit 1 end