poisol 0.0.6 → 0.0.7
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8abf193ecda6405403135d4a97ef83f8624a473d
|
4
|
+
data.tar.gz: 6437b016ab0c650a7cc8d538a9bcfbc9d7cae960
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92d9e28ab866ad697989d0606676873606a000206a1d8f7d05ffcd9c9f51f61fc2c91b50bd307084979c7f6255c4f750827eef18b6e3eea22934f9c4aae1bba3
|
7
|
+
data.tar.gz: 07e667e2ea26181722cc3bcf2a44474ee79735babd771e21803cadb67dcde5aa002f224413a7366831100f12b5ba816e1921e30a1f5f9a144e35ad5a1c907162
|
data/lib/poisol/stub_config.rb
CHANGED
@@ -41,9 +41,11 @@ class StubConfig
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def handle_resonse_array_type
|
44
|
-
return if @config_yml["response"].
|
44
|
+
return if @config_yml["response"].blank?
|
45
45
|
array_type = @config_yml["response"]["array_type"]
|
46
|
-
|
46
|
+
return if array_type.blank?
|
47
|
+
@response.is_column_array = true if array_type.eql? "column"
|
48
|
+
@response.is_row_array = true if array_type.eql? "row"
|
47
49
|
end
|
48
50
|
|
49
51
|
|
@@ -82,6 +84,6 @@ class Request
|
|
82
84
|
end
|
83
85
|
|
84
86
|
class Response
|
85
|
-
attr_accessor :body,:
|
87
|
+
attr_accessor :body,:is_column_array,:is_row_array
|
86
88
|
end
|
87
89
|
|
@@ -22,9 +22,7 @@ module ClassTemplate
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def build_response_body
|
25
|
-
if @config.response.
|
26
|
-
@response_body = Parse.hash_array_to_column_hash(@response_body)
|
27
|
-
end
|
25
|
+
@response_body = Parse.hash_array_to_column_hash(@response_body) if @config.response.is_column_array
|
28
26
|
@stub.to_return(:status => 200, :body => @response_body.to_s, :headers => {})
|
29
27
|
end
|
30
28
|
end
|
@@ -2,7 +2,11 @@ module ClassTemplate
|
|
2
2
|
|
3
3
|
def prepare_response
|
4
4
|
return if @config.response.body.blank?
|
5
|
-
@config.response.
|
5
|
+
if @config.response.is_column_array or @config.response.is_row_array
|
6
|
+
generate_methods_to_alter_response_array
|
7
|
+
else
|
8
|
+
generate_methods_to_alter_response_object
|
9
|
+
end
|
6
10
|
end
|
7
11
|
|
8
12
|
def generate_methods_to_alter_response_array
|
@@ -53,6 +57,13 @@ module ClassTemplate
|
|
53
57
|
end
|
54
58
|
end
|
55
59
|
|
60
|
+
def set_dumb_response response_file
|
61
|
+
@response_body = Parse.json_file_to_hash(response_file)
|
62
|
+
@config.response.is_column_array = false
|
63
|
+
@config.response.is_row_array = false
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
56
67
|
def generate_method_to_alter_response_field_array field_name,actual_field_values
|
57
68
|
actual_field_value = actual_field_values[0]
|
58
69
|
method_name = "has_#{field_name.classify.underscore}"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
describe ClassTemplate, "#dumb response" do
|
2
|
+
|
3
|
+
it "column array" do
|
4
|
+
Columns.new.set_dumb_response("data/user/response.json").build
|
5
|
+
response = RestClient.get "http://localhost:80/column"
|
6
|
+
expect(response.body).to eq( "{\"job\"=>\"sleeping_bag\"}")
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poisol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Deepak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- lib/poisol/utils/file_util.rb
|
144
144
|
- lib/poisol/utils/parse.rb
|
145
145
|
- spec/functional/array_spec.rb
|
146
|
+
- spec/functional/dumb_response_spec.rb
|
146
147
|
- spec/functional/get_spec.rb
|
147
148
|
- spec/functional/key_value/explicit_inclusion_spec.rb
|
148
149
|
- spec/functional/key_value/implicit_inclusion_spec.rb
|
@@ -182,4 +183,5 @@ test_files:
|
|
182
183
|
- spec/functional/key_value/implicit_inclusion_spec.rb
|
183
184
|
- spec/functional/post_spec.rb
|
184
185
|
- spec/functional/url_spec.rb
|
186
|
+
- spec/functional/dumb_response_spec.rb
|
185
187
|
- spec/functional/nested_array_spec.rb
|