Permalink
Browse files

Remove unsplated return value from #get_options! for ruby 1.9 compati…

…bility.
  • Loading branch information...
1 parent c53e720 commit 45cb66373d7661ebec9d30ef6d0609f9c9eb72af @metaskills metaskills committed with Dean Strelau May 11, 2009
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/shoulda/private_helpers.rb
  2. +6 −0 test/other/private_helpers_test.rb
@@ -7,7 +7,7 @@ def get_options!(args, *wanted)
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
@@ -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

0 comments on commit 45cb663

Please sign in to comment.