poisol 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/poisol/stub/request/query_builder.rb +3 -2
- data/lib/poisol/stub/stub.rb +2 -1
- data/lib/poisol/stub_config/stub_config.rb +1 -1
- data/lib/poisol/stub_config/stub_config_builder.rb +15 -3
- data/spec/data/main/key_value/explicit.yml +1 -1
- data/spec/data/main/{book.yml → query/book.yml} +1 -0
- data/spec/data/main/query/book_explicit.yml +19 -0
- data/spec/functional/query/query_explicit_spec.rb +15 -0
- data/spec/functional/{get_spec.rb → query/query_implicit_spec.rb} +2 -2
- data/spec/spec_helper.rb +1 -1
- metadata +9 -6
- data/lib/poisol/config_map.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdf61107e05bc60e3d83dcc816e0a246c788bd17
|
4
|
+
data.tar.gz: 0866588b30cf3921f5b0fc3f11755ee2aba83a95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b7c112d99da4648688618f8d5a9ee37f7fc8c111b5d68f1487c596e41b6abe938adf9bf6dd0f95092b526746d40b60244fb5ff07d08969f4b8af343514156da
|
7
|
+
data.tar.gz: 906006b5322d06de73e93c5110196f5628dff8869d4c8430748443c76477b6c32224166f117a203719eacdca57e5b5c77beb8fac04f9adc9a4752eb37f091e36
|
@@ -2,8 +2,9 @@ module QueryBuilder
|
|
2
2
|
def generate_query_methods
|
3
3
|
query = @stub_config.request.query
|
4
4
|
query.each do |field|
|
5
|
-
|
6
|
-
|
5
|
+
field_name = field[0]
|
6
|
+
define_method("for_#{field[0].underscore}") do |*value|
|
7
|
+
@request.query[field_name] = value[0]
|
7
8
|
self
|
8
9
|
end
|
9
10
|
end
|
data/lib/poisol/stub/stub.rb
CHANGED
@@ -20,8 +20,9 @@ class Stub
|
|
20
20
|
@response = Response.new
|
21
21
|
@request.url = stub_config.request.url.deep_dup
|
22
22
|
@request.query = stub_config.request.query.deep_dup
|
23
|
+
@request.query = {} if stub_config.request.query_explicit
|
23
24
|
@request.body = stub_config.request.body.deep_dup
|
24
|
-
@request.body = {} if stub_config.request.
|
25
|
+
@request.body = {} if stub_config.request.body_explicit
|
25
26
|
if stub_config.response.is_column_array or stub_config.response.is_row_array
|
26
27
|
@response.body = []
|
27
28
|
else
|
@@ -3,7 +3,7 @@ class StubConfig
|
|
3
3
|
end
|
4
4
|
|
5
5
|
class RequestConfig
|
6
|
-
attr_accessor :domain,:url,:type,:query,:body,:is_body_key_value,:
|
6
|
+
attr_accessor :domain,:url,:type,:query,:body,:is_body_key_value,:body_explicit,:query_explicit,:is_column_array,:is_row_array
|
7
7
|
end
|
8
8
|
|
9
9
|
class ResponseConfig
|
@@ -37,11 +37,23 @@ class StubConfigBuilder
|
|
37
37
|
def build_request
|
38
38
|
load_url
|
39
39
|
@stub_config.request.type = @raw_config_hash["request"]["type"].intern
|
40
|
-
|
40
|
+
load_query
|
41
|
+
load_request_body
|
42
|
+
end
|
43
|
+
|
44
|
+
def load_request_body
|
41
45
|
load_request_body_filed_implicit_option
|
42
46
|
@stub_config.is_inline ? load_inline_request_body : load_exploaded_request_body
|
43
47
|
end
|
44
48
|
|
49
|
+
|
50
|
+
def load_query
|
51
|
+
@stub_config.request.query = @raw_config_hash["request"]["query"]
|
52
|
+
query_explicit = @raw_config_hash["request"]["query_explicit"]
|
53
|
+
@stub_config.request.query_explicit = query_explicit.blank? ? false : query_explicit
|
54
|
+
end
|
55
|
+
|
56
|
+
|
45
57
|
def load_url
|
46
58
|
url = @raw_config_hash["request"]["url"]
|
47
59
|
url.strip!
|
@@ -50,8 +62,8 @@ class StubConfigBuilder
|
|
50
62
|
end
|
51
63
|
|
52
64
|
def load_request_body_filed_implicit_option
|
53
|
-
|
54
|
-
@stub_config.request.
|
65
|
+
body_explicit = @raw_config_hash["request"]["body_explicit"]
|
66
|
+
@stub_config.request.body_explicit = body_explicit.blank? ? false : body_explicit
|
55
67
|
end
|
56
68
|
|
57
69
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
request:
|
2
|
+
url: book_explicit
|
3
|
+
type: get
|
4
|
+
query_explicit: true
|
5
|
+
query:
|
6
|
+
author: "bharathi"
|
7
|
+
name: "doni"
|
8
|
+
response:
|
9
|
+
body: '{
|
10
|
+
"title": "independance",
|
11
|
+
"category": {
|
12
|
+
"age_group": "10",
|
13
|
+
"genre": "action",
|
14
|
+
"publisher": {
|
15
|
+
"name": "summa",
|
16
|
+
"place":"erode"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
describe Stub, "#query_explicit" do
|
2
|
+
|
3
|
+
it "partial" do
|
4
|
+
BookExplicit.new.for_author('bha').build()
|
5
|
+
response = RestClient.get "http://localhost:80/book_explicit",{:params => {:author=>'bha'}}
|
6
|
+
expect(response.body).to eq({"title"=>"independance", "category"=>{"age_group"=>"10", "genre"=>"action", "publisher"=>{"name"=>"summa", "place"=>"erode"}}}.to_json)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "full dymamic" do
|
10
|
+
Book.new.for_author('asd').for_name('don').build()
|
11
|
+
response = RestClient.get "http://localhost:80/book",{:params => {:author=>'asd',:name=>'don'}}
|
12
|
+
expect(response.body).to eq({"title"=>"independance", "category"=>{"age_group"=>"10", "genre"=>"action", "publisher"=>{"name"=>"summa", "place"=>"erode"}}}.to_json)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -2,13 +2,13 @@ describe Stub, "#get_books" do
|
|
2
2
|
|
3
3
|
it "dynamic response" do
|
4
4
|
Book.new.has_category({"age_group"=>"11", "publisher"=>{"name"=>"oxford"}}).build()
|
5
|
-
response = RestClient.get "http://localhost:80/book",{:params => {:author=>'bharathi'}}
|
5
|
+
response = RestClient.get "http://localhost:80/book",{:params => {:author=>'bharathi',:name=>"doni"}}
|
6
6
|
expect(response.body).to eq({"title"=>"independance", "category"=>{"age_group"=>"11", "genre"=>"action", "publisher"=>{"name"=>"oxford", "place"=>"erode"}}}.to_json)
|
7
7
|
end
|
8
8
|
|
9
9
|
it "default request and response" do
|
10
10
|
Book.new.build()
|
11
|
-
response = RestClient.get "http://localhost:80/book",{:params => {:author=>'bharathi'}}
|
11
|
+
response = RestClient.get "http://localhost:80/book",{:params => {:author=>'bharathi',:name=>"doni"}}
|
12
12
|
expect(response.body).to eq({"title"=>"independance", "category"=>{"age_group"=>"10", "genre"=>"action", "publisher"=>{"name"=>"summa", "place"=>"erode"}}}.to_json)
|
13
13
|
end
|
14
14
|
|
data/spec/spec_helper.rb
CHANGED
@@ -20,7 +20,7 @@ RSpec.configure do |config|
|
|
20
20
|
end
|
21
21
|
|
22
22
|
config.before(:suite) do
|
23
|
-
WebMock.disable_net_connect!
|
23
|
+
WebMock.disable_net_connect!
|
24
24
|
factory = StubFactory.new.build("spec/data/main")
|
25
25
|
factory = StubFactory.new.build("spec/data/domain/first/")
|
26
26
|
factory = StubFactory.new.build("spec/data/domain/second/")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Deepak
|
@@ -130,7 +130,6 @@ extra_rdoc_files: []
|
|
130
130
|
files:
|
131
131
|
- README.md
|
132
132
|
- lib/poisol.rb
|
133
|
-
- lib/poisol/config_map.rb
|
134
133
|
- lib/poisol/domain.rb
|
135
134
|
- lib/poisol/extensions/webmock_extensions.rb
|
136
135
|
- lib/poisol/stub/request/query_builder.rb
|
@@ -153,23 +152,25 @@ files:
|
|
153
152
|
- spec/data/domain/second/second.yml
|
154
153
|
- spec/data/main/array/columns.yml
|
155
154
|
- spec/data/main/array/rows.yml
|
156
|
-
- spec/data/main/book.yml
|
157
155
|
- spec/data/main/domain.yml
|
158
156
|
- spec/data/main/key_value/explicit.yml
|
159
157
|
- spec/data/main/key_value/key_value.yml
|
160
158
|
- spec/data/main/nested_array.yml
|
159
|
+
- spec/data/main/query/book.yml
|
160
|
+
- spec/data/main/query/book_explicit.yml
|
161
161
|
- spec/data/main/url.yml
|
162
162
|
- spec/data/main/user/config.yml
|
163
163
|
- spec/data/main/user/request.json
|
164
164
|
- spec/data/main/user/response.json
|
165
165
|
- spec/functional/array_spec.rb
|
166
166
|
- spec/functional/dumb_response_spec.rb
|
167
|
-
- spec/functional/get_spec.rb
|
168
167
|
- spec/functional/key_value/explicit_inclusion_spec.rb
|
169
168
|
- spec/functional/key_value/implicit_inclusion_spec.rb
|
170
169
|
- spec/functional/multi_domain_spec.rb
|
171
170
|
- spec/functional/nested_array_spec.rb
|
172
171
|
- spec/functional/post_spec.rb
|
172
|
+
- spec/functional/query/query_explicit_spec.rb
|
173
|
+
- spec/functional/query/query_implicit_spec.rb
|
173
174
|
- spec/functional/url_spec.rb
|
174
175
|
- spec/spec_helper.rb
|
175
176
|
- spec/unit/exception_spec.rb
|
@@ -213,16 +214,18 @@ test_files:
|
|
213
214
|
- spec/data/main/nested_array.yml
|
214
215
|
- spec/data/main/key_value/explicit.yml
|
215
216
|
- spec/data/main/key_value/key_value.yml
|
216
|
-
- spec/data/main/
|
217
|
+
- spec/data/main/query/book_explicit.yml
|
218
|
+
- spec/data/main/query/book.yml
|
217
219
|
- spec/unit/exception_spec.rb
|
218
220
|
- spec/unit/stub_spec.rb
|
219
221
|
- spec/spec_helper.rb
|
220
222
|
- spec/functional/multi_domain_spec.rb
|
221
223
|
- spec/functional/array_spec.rb
|
222
|
-
- spec/functional/get_spec.rb
|
223
224
|
- spec/functional/key_value/explicit_inclusion_spec.rb
|
224
225
|
- spec/functional/key_value/implicit_inclusion_spec.rb
|
225
226
|
- spec/functional/post_spec.rb
|
226
227
|
- spec/functional/url_spec.rb
|
227
228
|
- spec/functional/dumb_response_spec.rb
|
228
229
|
- spec/functional/nested_array_spec.rb
|
230
|
+
- spec/functional/query/query_implicit_spec.rb
|
231
|
+
- spec/functional/query/query_explicit_spec.rb
|