poisol 0.0.4 → 0.0.5

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: 102174b8f05e7b43926297e717bc76c7c3b81d46
4
- data.tar.gz: 829318caf733df87e6f9c26c2980c6bc6b3d08d7
3
+ metadata.gz: ab045c2db93e3a33c6e1600cd750e705570d8fb8
4
+ data.tar.gz: 7ff62860c55c2aa5d14ed1bc23d5aed18b5263ab
5
5
  SHA512:
6
- metadata.gz: c62558579d2916b39ec215446b895fed0917c99cd75dd4c9bae47722df202f78f167d0bf1f5159a214c3e40b01063ee3610048323765f33c43aeda8b695e087c
7
- data.tar.gz: 290dcda3d475dfcd579ad959b44c885ae93e42229eb577a101a57fac5137a5b661b07c37658fa16d276378e13370d7123748c9845d92007cc2c926055c443924
6
+ metadata.gz: 4c443130b5f4301c78c50f5b4548d72f6ea4b80c09b667b2f650dacb1eb5d125e24da914c9e0d5d7df070bc817b324c4bf34d45491947f37c9674f84a30b9d0a
7
+ data.tar.gz: 497f8874d31157962385508373fc65a342d6ad111bdcdc971f754c6c1cb6d07bd9ae46da9d79bbe1e2fb1e30351b43a552e7ec617830840762f5cccb73026c6f
data/README.md CHANGED
@@ -57,7 +57,6 @@ The following can be dynamically configured
57
57
  |with|response body array item field|
58
58
 
59
59
  ##ToDo
60
- * URL config
61
60
  * Response code and header config
62
61
  * Functional test for query params
63
62
  * Refactor Response Handler
@@ -14,7 +14,7 @@ module ClassTemplate
14
14
  end
15
15
 
16
16
  def prepare_request_url
17
- @url = @config.request.url
17
+ generate_methods_to_alter_path_params
18
18
  @type = @config.request.type
19
19
  end
20
20
 
@@ -27,6 +27,7 @@ module ClassTemplate
27
27
  end
28
28
 
29
29
  def build
30
+ remove_path_param_name_from_url
30
31
  stub = stub_request(@type, "http://#{Domain.base_url}/#{@url}")
31
32
  stub.with(:query => @query) unless @query.eql? ""
32
33
  stub.with(:body => @request_body) unless @request_body.eql? ""
@@ -0,0 +1,26 @@
1
+ module ClassTemplate
2
+ def generate_methods_to_alter_path_params
3
+ @url = @config.request.url.clone
4
+ @url.scan(/{(.+?)}/).each do |path_params|
5
+ path_param = path_params[0]
6
+ param_name = path_param.split("|")[0]
7
+ param_default_value = path_param.split("|")[1]
8
+ method_name = "for_#{param_name.underscore}"
9
+ define_singleton_method(method_name) do |*input_value|
10
+ input_value = input_value[0]
11
+ @url = @url.sub("{#{path_param}}","{#{param_name}|#{input_value}}") unless input_value.blank?
12
+ self
13
+ end
14
+ end
15
+ end
16
+
17
+
18
+ def remove_path_param_name_from_url
19
+ @url.scan(/{(.+?)}/).each do |path_params|
20
+ path_param = path_params[0]
21
+ param_name = path_param.split("|")[0]
22
+ param_value = path_param.split("|")[1]
23
+ @url.sub!("{#{path_param}}",param_value)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ describe ClassTemplate, "#url" do
2
+
3
+ it "default" do
4
+ Url.new.build()
5
+ response = RestClient.get "http://localhost:80/cda/cd/ragavan/get"
6
+ expect(response.body).to eq({"hi"=>1}.to_s)
7
+ end
8
+
9
+ it "dynamic" do
10
+ Url.new.for_name("hitler").for_actor("mani").build()
11
+ response = RestClient.get "http://localhost:80/cda/hitler/mani/get"
12
+ expect(response.body).to eq({"hi"=>1}.to_s)
13
+ end
14
+
15
+ it "partial" do
16
+ Url.new.for_actor("mani").build()
17
+ response = RestClient.get "http://localhost:80/cda/cd/mani/get"
18
+ expect(response.body).to eq({"hi"=>1}.to_s)
19
+ end
20
+
21
+ end
22
+
23
+
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
4
+ version: 0.0.5
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-02 00:00:00.000000000 Z
11
+ date: 2014-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -138,12 +138,14 @@ files:
138
138
  - lib/poisol/template/query_handler.rb
139
139
  - lib/poisol/template/request_handler.rb
140
140
  - lib/poisol/template/response_handler.rb
141
+ - lib/poisol/template/url_handler.rb
141
142
  - lib/poisol/utils/file_util.rb
142
143
  - lib/poisol/utils/parse.rb
143
144
  - spec/functional/array_spec.rb
144
145
  - spec/functional/get_spec.rb
145
146
  - spec/functional/nested_array_spec.rb
146
147
  - spec/functional/post_spec.rb
148
+ - spec/functional/url_spec.rb
147
149
  - spec/spec_helper.rb
148
150
  homepage: https://github.com/paramadeep/poisol
149
151
  licenses:
@@ -174,4 +176,5 @@ test_files:
174
176
  - spec/functional/array_spec.rb
175
177
  - spec/functional/get_spec.rb
176
178
  - spec/functional/post_spec.rb
179
+ - spec/functional/url_spec.rb
177
180
  - spec/functional/nested_array_spec.rb