-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyword_arguments_test.rb
58 lines (47 loc) · 1.35 KB
/
keyword_arguments_test.rb
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# frozen_string_literal: true
require "test_helper"
class KeywordArgumentsTest < Minitest::Test
include KeywordTestHelper
def setup
# refresh caller class to make sure keyword-related warnings
# will be output each time
reload! :DelegationWithKeywordArgs, 'delegation_samples/keyword'
@caller = DelegationWithKeywordArgs.new
end
def test_get_method_handles_null_option_properly
result, err = with_error do
result = @caller.put(:foo)
end
if RUBY_VERSION < "2.7"
assert_equal [:foo, {}], result
else
assert_equal [:foo], result
end
assert_empty err
end
def test_get_method_handles_empty_bracket_with_warnings
result, err = with_error do
result = @caller.put(:foo, {})
end
if RUBY_VERSION < "2.7"
assert_equal [:foo, {}], result
else
assert_equal [:foo], result
end
assert_empty err
end
def test_get_method_handles_keyword_arguments_properly
result, err = with_error do
result = @caller.put(:foo, bar: :baz, qux: 123)
end
assert_equal [:foo, { bar: :baz, qux: 123 }], result
assert_empty err
end
def test_get_method_handles_hash_objects_with_warnings
result, err = with_error do
result = @caller.put(:foo, { bar: :baz, qux: 123 })
end
assert_equal [:foo, { bar: :baz, qux: 123 }], result
assert_empty err
end
end