poisol 0.0.14 → 0.0.16

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: 4b9c429f0834704fa230eea61510e8321d84ec19
4
- data.tar.gz: f8ba272736a48e27c5157d3f1574e265d3659a97
3
+ metadata.gz: 746cc1b4593b122301c0254b8282f6d9456223a7
4
+ data.tar.gz: 75c873a3936300e4f0d00a659b8286039ba26ae1
5
5
  SHA512:
6
- metadata.gz: 2c674f53f0fb8dd6f8195fe35ddbdcfb6a97b8e87ac6813c370747f967ccc481c4443ffafe8b6baf6d4e96b18170e4c2f0b70324d440ef1b2cdee3bc48e2524b
7
- data.tar.gz: 894a79f9c01dfa6e61a5085233bcacdda6e696721edae710e9161050c4daa7913f404341cc9207e55a1468520016aa1e8cde90667e258eab2eb2b577fc9978d8
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 = is_array ? ("with_#{field_name.classify.underscore}") : ("with_#{field_name.underscore}")
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] = is_array ? (@response.body.last[field_name] << assignment_value) : assignment_value
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
@@ -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
@@ -21,5 +21,9 @@ class PoisolLog
21
21
  logger.warn "#{message}\n"
22
22
  end
23
23
 
24
+ def debug message
25
+ logger.debug "#{message}\n"
26
+ end
27
+
24
28
  end
25
29
  end
@@ -5,6 +5,7 @@ response:
5
5
  array_type: row
6
6
  body: '{
7
7
  "title": "independance",
8
+ "items": [1,2],
8
9
  "category": {
9
10
  "age_group": "10"
10
11
  }
@@ -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("role_id"=>"test1").build()
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("role_id"=>"test").build()
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.14
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-18 00:00:00.000000000 Z
11
+ date: 2014-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec