Permalink
Browse files

Allow default options in with_options to be overridden. Closes #4480.…

… [murphy@cYcnus.de]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4282 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
Marcel Molina
Marcel Molina committed Apr 26, 2006
1 parent ca2eb16 commit 71ff705449aa0cc38baa746c07d2520fdb64096a
View
@@ -1,5 +1,7 @@
*SVN*
* Allow default options in with_options to be overridden. Closes #4480. [murphy@cYcnus.de]
* Added Module#alias_method_chain [Jamis Buck]
* Updated to Builder 2.0 [DHH]
@@ -15,8 +15,8 @@ def method_missing(method, *arguments, &block)
end
def merge_argument_options!(arguments)
arguments << if arguments.last.respond_to? :merge!
arguments.pop.dup.merge!(@options)
arguments << if arguments.last.respond_to? :to_hash
@options.merge(arguments.pop)
else
@options.dup
end
@@ -27,6 +27,22 @@ def test_method_with_options_appends_options_when_options_are_missing
end
end
def test_method_with_options_allows_to_overwrite_options
local_options = {:hello => 'moon'}
assert_equal @options.keys, local_options.keys
with_options(@options) do |o|
assert_equal local_options, method_with_options(local_options)
assert_equal @options.merge(local_options),
o.method_with_options(local_options)
assert_equal local_options, o.method_with_options(local_options)
end
with_options(local_options) do |o|
assert_equal local_options.merge(@options),
o.method_with_options(@options)
end
end
private
def method_with_options(options = {})
options

0 comments on commit 71ff705

Please sign in to comment.