Skip to content

Commit

Permalink
Remove unsplated return value from #get_options! for ruby 1.9 compati…
Browse files Browse the repository at this point in the history
…bility.
  • Loading branch information
metaskills authored and Dean Strelau committed Jun 3, 2009
1 parent c53e720 commit 45cb663
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/shoulda/private_helpers.rb
Expand Up @@ -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
6 changes: 6 additions & 0 deletions test/other/private_helpers_test.rb
Expand Up @@ -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.