restpack_service 0.0.49 → 0.0.50

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88bf57be3cb2a8793e48dba0b6a4880e532edcae
4
- data.tar.gz: aa16567dcd95fdba3c1398718061b7067d2026a7
3
+ metadata.gz: f3112cdda0292cda0db626c31d7a02f5857a51dc
4
+ data.tar.gz: fb3e69799b34841231f20abfefb4495ae10af712
5
5
  SHA512:
6
- metadata.gz: 7def19a26144ecb00da33b06a1aedee53c6de67bc0d2647d85c7ccf82f858db6c5332466b3beff72843a3adcb69060f8241bccd63cbdd4e7829efb579285e7ac
7
- data.tar.gz: 0cadb8702785bd6bc285da3be729f3cf5b3ef06ea3ec23d677963be9e078f1fb92fdf4deefb9578c31f5c1b4814527f51d8a44f8482cc8365a58263f54751ff9
6
+ metadata.gz: 659587c99edeb9aaabd36118968865249b6656fb328118ddb4718a434eb815101a1eac5189f1676c340497e2ba4ebf86fdc234e5c04b1bc178367d27198135da
7
+ data.tar.gz: 4b59eeeead5333ebacafb90a2aab6e0d5e28d0dd43cd543c8c2e7ea7d065ec53061ed9b8c880f46e49c3f5ec8775dcbc90789c9e88b1f72647b20c5cb9e2a688
@@ -0,0 +1,40 @@
1
+ def it_acts_as_create_command(type)
2
+ plural = "#{type}s".to_sym
3
+ model_class = "Models::#{type.capitalize}".constantize
4
+ serializer_class = "Serializers::#{type.capitalize}".constantize
5
+
6
+ let(:response) { subject.class.run(params) }
7
+
8
+ context "with valid params" do
9
+ context "when creating a single item" do
10
+ let(:item) { build("api_#{type}".to_sym) }
11
+ let(:params) { { plural => [item] } }
12
+
13
+ it "returns the newly created #{type}" do
14
+ response.success?.should == true
15
+ response.result.should include(plural), "The reponse should include :#{plural} array"
16
+
17
+ response_items = response.result[plural]
18
+ response_items.length.should == 1
19
+ response_item = response_items.first
20
+
21
+ model = model_class.find(response_item[:id])
22
+ response_item.should == serializer_class.as_json(model)
23
+ end
24
+ end
25
+
26
+ context "when creating multiple items" do
27
+ let(:item1) { build("api_#{type}".to_sym) }
28
+ let(:item2) { build("api_#{type}".to_sym) }
29
+ let(:params) { { plural => [item1, item2] } }
30
+
31
+ it "returns the newly created #{type}s" do
32
+ response.success?.should == true
33
+ response.result.should include(plural), "The reponse should include :#{plural} array"
34
+
35
+ response_items = response.result[plural]
36
+ response_items.length.should == 2
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,3 +1,5 @@
1
+ require_relative 'matchers/create_command'
2
+
1
3
  def is_required(*params)
2
4
  params.each do |param|
3
5
  it ":#{param} parameter must be required" do
@@ -30,44 +32,3 @@ def service_should_map(param, map)
30
32
  end
31
33
  end
32
34
  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("api_#{type}".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("api_#{type}".to_sym) }
61
- let(:item2) { build("api_#{type}".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.49"
3
+ VERSION = "0.0.50"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restpack_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.49
4
+ version: 0.0.50
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Joyce
@@ -213,6 +213,7 @@ files:
213
213
  - lib/restpack_service/loader.rb
214
214
  - lib/restpack_service/response.rb
215
215
  - lib/restpack_service/support/matchers.rb
216
+ - lib/restpack_service/support/matchers/create_command.rb
216
217
  - lib/restpack_service/support/spec_helper.rb
217
218
  - lib/restpack_service/version.rb
218
219
  - restpack_service.gemspec