restpack_service 0.0.46 → 0.0.47
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.
- checksums.yaml +4 -4
- data/lib/restpack_service/support/matchers.rb +41 -0
- data/lib/restpack_service/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a7926c39f66b339a0af40698b6a8e55450b9162
|
4
|
+
data.tar.gz: d26298f2eddc7e7776a71922f01b67cd338c4985
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da191908304fd39b93fa3dacfc7c5254235f21a7fb96117b8457673a7ea4ba96148b6f339bf9ec538724962940d57c7c3295bbf678d6e8ef44dbb855bed71552
|
7
|
+
data.tar.gz: 87bf4b746cdfed03e250f301af8cc2fd2da0ff71b0476de695034937d823eb93672f232248ce882d3fbf7137d4c3e4df5e9a190f46e8b34c5ed6d6b3d5702dcc
|
@@ -30,3 +30,44 @@ def service_should_map(param, map)
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
def it_acts_as_create_command(type)
|
35
|
+
plural = "#{type}s".to_sym
|
36
|
+
model_class = "Models::#{type.capitalize}".constantize
|
37
|
+
serializer_class = "Serializers::#{type.capitalize}".constantize
|
38
|
+
|
39
|
+
let(:response) { subject.class.run(params) }
|
40
|
+
|
41
|
+
context "with valid params" do
|
42
|
+
context "when creating a single item" do
|
43
|
+
let(:item) { build("#{type}_request".to_sym) }
|
44
|
+
let(:params) { { plural => [item] } }
|
45
|
+
|
46
|
+
it "returns the newly created #{type}" do
|
47
|
+
response.success?.should == true
|
48
|
+
response.result.should include(plural), "The reponse should include :#{plural} array"
|
49
|
+
|
50
|
+
response_items = response.result[plural]
|
51
|
+
response_items.length.should == 1
|
52
|
+
response_item = response_items.first
|
53
|
+
|
54
|
+
model = model_class.find(response_item[:id])
|
55
|
+
response_item.should == serializer_class.as_json(model)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "when creating multiple items" do
|
60
|
+
let(:item1) { build("#{type}_request".to_sym) }
|
61
|
+
let(:item2) { build("#{type}_request".to_sym) }
|
62
|
+
let(:params) { { plural => [item1, item2] } }
|
63
|
+
|
64
|
+
it "returns the newly created #{type}s" do
|
65
|
+
response.success?.should == true
|
66
|
+
response.result.should include(plural), "The reponse should include :#{plural} array"
|
67
|
+
|
68
|
+
response_items = response.result[plural]
|
69
|
+
response_items.length.should == 2
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restpack_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.47
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Joyce
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mutations
|