poisol 0.0.14 → 0.0.16
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/poisol/extensions/webmock_extensions.rb +1 -1
- data/lib/poisol/stub/response/response_body_builder.rb +13 -2
- data/lib/poisol/stub/stub_instance.rb +1 -1
- data/lib/poisol/stub_factory.rb +4 -0
- data/lib/poisol/utils/logger.rb +4 -0
- data/spec/data/main/response/array/rows.yml +1 -0
- data/spec/functional/response/array_spec.rb +4 -4
- data/spec/functional/response/nested_array_spec.rb +2 -2
- 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: 746cc1b4593b122301c0254b8282f6d9456223a7
|
4
|
+
data.tar.gz: 75c873a3936300e4f0d00a659b8286039ba26ae1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0fa5a89c43db7bb178f57ae7ed870d8c1769f656ce9da3b1d77c61ec915bcadeb63d4ca64a32ab75a63f64274ce5c964d95a37df2675a77ee4a30f1d7d325bb
|
7
|
+
data.tar.gz: 59b55b3da2eb5f9a3cb530566104f8ca93e3ee2a87c22d42652db89050ca6c7c569b49dc4ac5db59d28f7de9ea7315d33eda25990c583e266bd3b0db6c63e0c8
|
@@ -4,7 +4,7 @@ module WebMock
|
|
4
4
|
def initialize(*args)
|
5
5
|
exception = real_init *args
|
6
6
|
request = args[0]
|
7
|
-
PoisolLog.error "**************Failed************\n#{request.method}:#{request.uri}\n#{request.body if request.body.present?}"
|
7
|
+
PoisolLog.error "**************Failed************\n#{request.method}:#{request.uri}\n#{request.body if request.body.present?}\n#{request_stubs}"
|
8
8
|
exception
|
9
9
|
end
|
10
10
|
end
|
@@ -22,13 +22,24 @@ module ResponseBodyBuilder
|
|
22
22
|
actual_field_value = field[1]
|
23
23
|
is_array = (actual_field_value.class.to_s == "Array")
|
24
24
|
actual_field_value = actual_field_value[0] if is_array
|
25
|
-
method_name =
|
25
|
+
method_name = "with_#{field_name.underscore}"
|
26
26
|
define_method(method_name) do |*input_value|
|
27
27
|
input_value = input_value[0]
|
28
28
|
assignment_value = get_assignment_value actual_field_value,input_value
|
29
|
-
@response.body.last[field_name] =
|
29
|
+
@response.body.last[field_name] = assignment_value
|
30
30
|
self
|
31
31
|
end
|
32
|
+
|
33
|
+
if is_array
|
34
|
+
method_name = "with_#{field_name.classify.underscore}"
|
35
|
+
define_method(method_name) do |*input_value|
|
36
|
+
input_value = input_value[0]
|
37
|
+
assignment_value = get_assignment_value actual_field_value,input_value
|
38
|
+
@response.body.last[field_name] = @response.body.last[field_name] << assignment_value
|
39
|
+
self
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
32
43
|
end
|
33
44
|
end
|
34
45
|
|
@@ -30,7 +30,7 @@ module StubInstance
|
|
30
30
|
def get_assignment_value actual_field_value,input_value
|
31
31
|
if actual_field_value.class.to_s == "Hash"
|
32
32
|
input_value = {} if input_value.blank?
|
33
|
-
actual_field_value.deep_merge(input_value)
|
33
|
+
actual_field_value.deep_merge(input_value.stringify_keys)
|
34
34
|
else
|
35
35
|
input_value
|
36
36
|
end
|
data/lib/poisol/stub_factory.rb
CHANGED
@@ -24,6 +24,7 @@ class StubFactory
|
|
24
24
|
|
25
25
|
def generate_exploded_config explolded_configs
|
26
26
|
explolded_configs.each do |config_file|
|
27
|
+
PoisolLog.info "Processing #{config_file}"
|
27
28
|
dynamic_name = (FileName.get_dir_name config_file).camelize
|
28
29
|
config = StubConfigBuilder.new.is_exploded.with_file(config_file).with_domain(@domain.full_url).build
|
29
30
|
create_class dynamic_name,config
|
@@ -32,6 +33,7 @@ class StubFactory
|
|
32
33
|
|
33
34
|
def generate_inline_config inline_configs
|
34
35
|
inline_configs.each do |config_file|
|
36
|
+
PoisolLog.debug "Processing #{config_file}"
|
35
37
|
dynamic_name = (FileName.get_file_name config_file).camelize
|
36
38
|
stub_config = StubConfigBuilder.new.is_inline.with_file(config_file).with_domain(@domain.full_url).build
|
37
39
|
create_class dynamic_name,stub_config
|
@@ -42,6 +44,8 @@ class StubFactory
|
|
42
44
|
dynamic_stub_class = Object.const_set class_name,Class.new(Stub)
|
43
45
|
dynamic_stub_class.set_stub_config stub_config
|
44
46
|
dynamic_stub_class.generate_methods_to_alter_sutb
|
47
|
+
PoisolLog.info "Generated #{class_name}"
|
48
|
+
PoisolLog.debug "with methods #{dynamic_stub_class.instance_methods - Object.methods}"
|
45
49
|
end
|
46
50
|
|
47
51
|
end
|
data/lib/poisol/utils/logger.rb
CHANGED
@@ -31,21 +31,21 @@ describe Stub, "#array" do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "row array" do
|
34
|
-
Rows.new.has_row.has_row.with_title("abc").with_category("age_group" => "12").build
|
34
|
+
Rows.new.has_row.with_item(3).has_row.with_title("abc").with_category("age_group" => "12").with_items([2,3]).build
|
35
35
|
response = RestClient.get "http://localhost:80/row"
|
36
|
-
expect(response.body).to eq([{"title"=>"independance", "category"=>{"age_group"=>"10"}}, {"title"=>"abc", "category"=>{"age_group"=>"12"}}].to_json)
|
36
|
+
expect(response.body).to eq([{"title"=>"independance","items"=> [1,2,3],"category"=>{"age_group"=>"10"}}, {"title"=>"abc","items"=> [2,3],"category"=>{"age_group"=>"12"}}].to_json)
|
37
37
|
end
|
38
38
|
|
39
39
|
it "row array hash_params" do
|
40
40
|
Rows.new.has_row.has_row(:title=>"abc",:category=>{"age_group" => "12"}).build
|
41
41
|
response = RestClient.get "http://localhost:80/row"
|
42
|
-
expect(response.body).to eq([{"title"=>"independance", "category"=>{"age_group"=>"10"}}, {"title"=>"abc", "category"=>{"age_group"=>"12"}}].to_json)
|
42
|
+
expect(response.body).to eq([{"title"=>"independance", "items"=> [1,2],"category"=>{"age_group"=>"10"}}, {"title"=>"abc", "items"=> [1,2],"category"=>{"age_group"=>"12"}}].to_json)
|
43
43
|
end
|
44
44
|
|
45
45
|
it "row array full hash_params" do
|
46
46
|
Rows.new.has_rows([{},{:title=>"abc",:category=>{"age_group" => "12"}}]).build
|
47
47
|
response = RestClient.get "http://localhost:80/row"
|
48
|
-
expect(response.body).to eq([{"title"=>"independance", "category"=>{"age_group"=>"10"}}, {"title"=>"abc", "category"=>{"age_group"=>"12"}}].to_json)
|
48
|
+
expect(response.body).to eq([{"title"=>"independance", "items"=> [1,2],"category"=>{"age_group"=>"10"}}, {"title"=>"abc", "items"=> [1,2],"category"=>{"age_group"=>"12"}}].to_json)
|
49
49
|
end
|
50
50
|
|
51
51
|
|
@@ -19,13 +19,13 @@ describe Stub, "#nested array" do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "mentioning one field with altered values" do
|
22
|
-
NestedArray.new.has_role(
|
22
|
+
NestedArray.new.has_role(:role_id=>"test1").build()
|
23
23
|
response = RestClient.get "http://localhost:80/nested_array"
|
24
24
|
expect(response.body).to eq({"title"=>"ind", "roles"=>[{"role_id"=>"test1", "role_name"=>"sol"}]}.to_json)
|
25
25
|
end
|
26
26
|
|
27
27
|
it "multiple fields with altered values" do
|
28
|
-
NestedArray.new.has_role.has_another_role(
|
28
|
+
NestedArray.new.has_role.has_another_role(:role_id=>"test").build()
|
29
29
|
response = RestClient.get "http://localhost:80/nested_array"
|
30
30
|
expect(response.body).to eq({"title"=>"ind", "roles"=>[{"role_id"=>"chumma", "role_name"=>"sol"},{"role_id"=>"test", "role_name"=>"sol"}]}.to_json)
|
31
31
|
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.16
|
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-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|