poisol 0.1.4 → 0.1.5
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: 694d7cf950ecd96a78b73968192fc47335da892e
|
4
|
+
data.tar.gz: 5b3c8415adbcc0c6f4808d0a7bc28d89a0b56b08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acdd6c698dcbae2e11e8a7a277a61b8b73da52cd8177cfa1a5be524c4245aef018d37785c38f361c4bf04b0a51c04880b70f3889b2bb8b7c57056151d08b3224
|
7
|
+
data.tar.gz: 488bf8adb7cf80eb01fc2e12a31cca5b3ca2d45c2c87669280f89154948b35cd712d2e5c365ebb985ee6edf6d7017fc81cc913ed9c2b741ecfddddb97cc5672f
|
data/README.md
CHANGED
@@ -12,10 +12,10 @@ Hence, avoiding clumsy manual json manipulations and duplications, and keeping t
|
|
12
12
|
Stubbing a http service that provides user identification, gets as simple as
|
13
13
|
|
14
14
|
```ruby
|
15
|
-
User.new.
|
15
|
+
User.new.ofName('Joe').hasRole('buyer').build
|
16
16
|
# => webmock that would return role as 'buyer' for http call user 'Joe'
|
17
17
|
|
18
|
-
User.new.
|
18
|
+
User.new.ofName('Mani').hasRole('Manager').build
|
19
19
|
# => webmock that would return role as 'Manager' for http call user 'Mani'
|
20
20
|
|
21
21
|
User.new.build
|
@@ -30,10 +30,12 @@ query:
|
|
30
30
|
name: "Raji"
|
31
31
|
response_body:
|
32
32
|
'{
|
33
|
-
role: "singer"
|
33
|
+
role : "singer"
|
34
34
|
}'
|
35
35
|
```
|
36
|
-
Poisol, dynamically generates class called 'User', with methods '
|
36
|
+
Poisol, dynamically generates class called 'User', with methods 'ofName' and 'hasRole', which can be used to build as many User's as we need for the tests.
|
37
|
+
|
38
|
+
It handles complex request and responses, like array, nested array, array having nested array etc..
|
37
39
|
|
38
40
|
The following can be dynamically configured
|
39
41
|
- Request
|
@@ -42,25 +44,23 @@ The following can be dynamically configured
|
|
42
44
|
- query params
|
43
45
|
- request body
|
44
46
|
- Response
|
45
|
-
- code
|
47
|
+
- status code
|
46
48
|
- header
|
47
49
|
- response body
|
48
50
|
|
49
51
|
## Prepositions
|
50
52
|
|
51
|
-
|Preposition| for defining|
|
52
|
-
|
53
|
-
|of|url
|
54
|
-
|for|query params
|
55
|
-
|by|request body filed/array item|
|
56
|
-
|having|request body array item field|
|
57
|
-
|has|response body field/array item|
|
58
|
-
|with|response body array item field|
|
53
|
+
| Preposition | for defining |
|
54
|
+
| ----: | :---- |
|
55
|
+
| of | url |
|
56
|
+
| for | query params |
|
57
|
+
| by | request body filed/array item |
|
58
|
+
| having | request body array item field |
|
59
|
+
| has | response body field/array item |
|
60
|
+
| with | response body array item field |
|
59
61
|
|
60
62
|
##ToDo
|
61
63
|
* Response code and header config
|
62
|
-
* Functional test for query params
|
63
|
-
* Refactor Response Handler
|
64
64
|
* Generate Request Handler, based on Response Handler
|
65
65
|
* Documentation for 'getting started' and details
|
66
66
|
* Test coverage
|
@@ -32,7 +32,7 @@ module Poisol
|
|
32
32
|
@response.body[field_name] = []
|
33
33
|
input_hashes = input_value[0]
|
34
34
|
input_hashes.each do |input_hash|
|
35
|
-
assignment_value = get_assignment_value actual_field_value.deep_dup,input_hash
|
35
|
+
assignment_value = get_assignment_value actual_field_value.deep_dup,input_hash
|
36
36
|
@response.body[field_name] << assignment_value
|
37
37
|
end
|
38
38
|
self
|
@@ -18,7 +18,10 @@ module Poisol
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def query_matches? actual_req,stub_req
|
21
|
-
return actual_req.query==stub_req.query
|
21
|
+
return true if actual_req.query==stub_req.query
|
22
|
+
actual_query = CGI::parse(actual_req.query)
|
23
|
+
stub_query = CGI::parse(stub_req.query)
|
24
|
+
return matching_hashes? actual_query,stub_query
|
22
25
|
end
|
23
26
|
|
24
27
|
def body_matches? actual_req,stub_req
|
@@ -43,12 +46,12 @@ module Poisol
|
|
43
46
|
def matching_hashes?(actuals, expected)
|
44
47
|
return false unless actuals.keys.sort == expected.keys.sort
|
45
48
|
actuals.each do |key, actual|
|
46
|
-
|
49
|
+
expect = expected[key]
|
47
50
|
|
48
|
-
if actual.is_a?(Hash) &&
|
49
|
-
return false unless matching_hashes?(actual,
|
51
|
+
if actual.is_a?(Hash) && expect.is_a?(Hash)
|
52
|
+
return false unless matching_hashes?(actual, expect)
|
50
53
|
else
|
51
|
-
return false unless
|
54
|
+
return false unless expect === actual
|
52
55
|
end
|
53
56
|
end
|
54
57
|
true
|
@@ -26,6 +26,7 @@ module Poisol
|
|
26
26
|
PoisolLog.error "Registered requests are: #{Stubs.all.map{|stub| "\n#{stub.request.to_s}"}.join}\n--end--"
|
27
27
|
raise "No match found for request: #{stub_request.to_s} "
|
28
28
|
end
|
29
|
+
PoisolLog.info JSON.pretty_generate(stub.response.body)
|
29
30
|
return stub.response if stub.present?
|
30
31
|
end
|
31
32
|
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require_relative "../../lib/poisol/stub_mapper/request_matcher"
|
2
|
+
describe Poisol::RequestMatcher, "request matching" do
|
3
|
+
it "match hashes" do
|
4
|
+
hash1 = {"store_group_id"=>["5008"], "date"=>["2029-12-28"], "pr_discount_percentage"=>["0.00000"]}
|
5
|
+
hash2 = {"date"=>["2029-12-28"], "pr_discount_percentage"=>["0.00000"], "store_group_id"=>["5008"]}
|
6
|
+
expect(Poisol::RequestMatcher.matching_hashes?(hash1,hash2)).to eq true
|
7
|
+
end
|
8
|
+
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.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Deepak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -186,6 +186,7 @@ files:
|
|
186
186
|
- spec/spec_helper.rb
|
187
187
|
- spec/unit/exception_spec.rb
|
188
188
|
- spec/unit/extension/hash_spec.rb
|
189
|
+
- spec/unit/request_matcher_spec.rb
|
189
190
|
- spec/unit/stub_spec.rb
|
190
191
|
homepage: https://github.com/paramadeep/poisol
|
191
192
|
licenses:
|
@@ -230,6 +231,7 @@ test_files:
|
|
230
231
|
- spec/data/main/query/book_explicit.yml
|
231
232
|
- spec/data/main/query/book.yml
|
232
233
|
- spec/unit/extension/hash_spec.rb
|
234
|
+
- spec/unit/request_matcher_spec.rb
|
233
235
|
- spec/unit/exception_spec.rb
|
234
236
|
- spec/unit/stub_spec.rb
|
235
237
|
- spec/spec_helper.rb
|