rest-in-peace 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.1
|
@@ -10,7 +10,7 @@ module RESTinPeace
|
|
10
10
|
|
11
11
|
def get(method_name, url_template, default_params = {})
|
12
12
|
@target.rip_registry[:collection] << { method: :get, name: method_name, url: url_template }
|
13
|
-
@target.send(:define_singleton_method, method_name) do |given_params|
|
13
|
+
@target.send(:define_singleton_method, method_name) do |given_params = {}|
|
14
14
|
params = default_params.merge(given_params)
|
15
15
|
|
16
16
|
call = RESTinPeace::ApiCall.new(api, url_template, self, params)
|
@@ -55,20 +55,33 @@ describe RESTinPeace::DefinitionProxy::CollectionMethodDefinitions do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
describe 'parameter and arguments handling' do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
context 'with given attributes' do
|
59
|
+
it 'uses the given attributes' do
|
60
|
+
expect(RESTinPeace::ApiCall).to receive(:new).
|
61
|
+
with(target.api, '/a', target, {name: 'daniele', last_name: 'in der o'}).
|
62
|
+
and_return(api_call_double)
|
62
63
|
|
63
|
-
|
64
|
-
|
64
|
+
subject.get(:all, '/a', {last_name: 'in der o'})
|
65
|
+
target.all(name: 'daniele')
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'does not modify the default params' do
|
69
|
+
default_params = { per_page: 250 }
|
70
|
+
subject.get(:find, '/a/:id', default_params)
|
71
|
+
target.find(id: 1)
|
72
|
+
expect(default_params).to eq({ per_page: 250 })
|
73
|
+
end
|
65
74
|
end
|
66
75
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
76
|
+
context 'without any attributes' do
|
77
|
+
it 'uses the default params' do
|
78
|
+
expect(RESTinPeace::ApiCall).to receive(:new).
|
79
|
+
with(target.api, '/a', target, {last_name: 'in der o'}).
|
80
|
+
and_return(api_call_double)
|
81
|
+
|
82
|
+
subject.get(:all, '/a', {last_name: 'in der o'})
|
83
|
+
target.all
|
84
|
+
end
|
72
85
|
end
|
73
86
|
end
|
74
87
|
end
|