Skip to content

Commit 00a232b

Browse files
committedApr 26, 2021
create failing spec for keyword args proxy
when the proxy fails to forward keywoard arguments, the error for methods that only accept keyword arguments looks like this: ArgumentError: wrong number of arguments (given 1, expected 0)
1 parent a4ec07b commit 00a232b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed
 

‎elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Licensed to Elasticsearch B.V. under one or more contributor
1+
22
# license agreements. See the NOTICE file distributed with
33
# this work for additional information regarding copyright
44
# ownership. Elasticsearch B.V. licenses this file to you under
@@ -31,6 +31,10 @@ def bar
3131
'insta barr'
3232
end
3333

34+
def keyword_method(foo: 'default value')
35+
foo
36+
end
37+
3438
def as_json(options)
3539
{foo: 'bar'}
3640
end
@@ -98,7 +102,6 @@ def changes_to_save
98102
end
99103

100104
context 'when instances are cloned' do
101-
102105
let!(:model) do
103106
DummyProxyModel.new
104107
end
@@ -121,4 +124,9 @@ def changes_to_save
121124
expect(duplicate).to eq(duplicate_target)
122125
end
123126
end
127+
128+
it 'forwards keyword arguments to target methods' do
129+
expect(DummyProxyModel.new.__elasticsearch__.keyword_method(foo: 'bar')).to eq('bar')
130+
end
131+
124132
end

0 commit comments

Comments
 (0)