Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…bility.
  • Loading branch information...
commit 45cb66373d7661ebec9d30ef6d0609f9c9eb72af 1 parent c53e720
@metaskills metaskills authored Dean Strelau committed
View
2  lib/shoulda/private_helpers.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
View
6 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
Please sign in to comment.
Something went wrong with that request. Please try again.