restpack_service 0.0.46 → 0.0.47

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bec0b10d2eb5b427542de2e71f54606449337562
4
- data.tar.gz: 7cb2e1f25acd87b3a3cef8d0b2beda12d8e36189
3
+ metadata.gz: 7a7926c39f66b339a0af40698b6a8e55450b9162
4
+ data.tar.gz: d26298f2eddc7e7776a71922f01b67cd338c4985
5
5
  SHA512:
6
- metadata.gz: f915ea644e36a8960448160c9be5526fa8c27b2b09824a77f36c5f7792d247cc9de04a58b426139c85abb2f91aa7daceb073afe3d9f007aa0067646d436bb493
7
- data.tar.gz: ee2997d73b7a1720031d8659a4fd0caf4816bfaf34d9728f8559aac081a18cf7ffdfc2577b98bc3d73472b02baffa9442a66a130510e1bd889d570420e035536
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
@@ -1,5 +1,5 @@
1
1
  module RestPack
2
2
  module Service
3
- VERSION = "0.0.46"
3
+ VERSION = "0.0.47"
4
4
  end
5
5
  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.46
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 00:00:00.000000000 Z
11
+ date: 2013-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mutations