blob: baa2cd30f37481c601f470eb1bc78a17e7f78e5e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
require 'test/unit'
unless defined? ActiveSupport::OptionMerger
require File.dirname(__FILE__) + '/../lib/active_support/option_merger'
require File.dirname(__FILE__) + '/../lib/active_support/core_ext/object_and_class'
end
class OptionMergerTest < Test::Unit::TestCase
def setup
@options = {:hello => 'world'}
end
def test_method_with_options_merges_options_when_options_are_present
local_options = {:cool => true}
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)
end
end
def test_method_with_options_appends_options_when_options_are_missing
with_options(@options) do |o|
assert_equal Hash.new, method_with_options
assert_equal @options, o.method_with_options
end
end
private
def method_with_options(options = {})
options
end
end
|