poisol 0.1.0 → 0.1.1
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/response_mapper.rb +6 -1
- data/lib/poisol/stub/stub.rb +5 -0
- data/lib/poisol/stubs.rb +5 -2
- data/lib/poisol/utils/logger.rb +4 -4
- data/lib/poisol.rb +3 -9
- data/spec/spec_helper.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 792f598402da3cf3e020eda9cbd549ae4a580557
|
4
|
+
data.tar.gz: 043b756d73700adc34239e7224c88fb674069af4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d754abd04577b373ad452161bab9337b5ef51a7fd90bc41d2c5c114400d83fd1bf651698a696678a0459397982298f13d756521e9df377d28578f4256719204
|
7
|
+
data.tar.gz: 0cfc85a52f8894577c12487610452e87542a53c74c2f43445f82ba47bcca3372b9957c273be187c7dc55b3e7246c6c9bbddb8d164b59bf1c5500272b0ba241ad
|
@@ -3,6 +3,7 @@ module ResponseMapper
|
|
3
3
|
|
4
4
|
def map webrick_request
|
5
5
|
stub_request = get_stub_request webrick_request
|
6
|
+
PoisolLog.info stub_request.to_s
|
6
7
|
stub_response = get_stub_response stub_request
|
7
8
|
end
|
8
9
|
|
@@ -19,7 +20,11 @@ module ResponseMapper
|
|
19
20
|
|
20
21
|
def get_stub_response stub_request
|
21
22
|
stub = Stubs.get_match stub_request
|
22
|
-
|
23
|
+
if stub.blank?
|
24
|
+
PoisolLog.error "^^^^^^^^^^^^\nNo match found for above request"
|
25
|
+
PoisolLog.error "Registered requests are #{Stubs.all.map{|stub| "#{stub.request.to_s}\n"}.join}"
|
26
|
+
raise "No match found for request: #{stub_request.to_s} "
|
27
|
+
end
|
23
28
|
return stub.response if stub.present?
|
24
29
|
end
|
25
30
|
|
data/lib/poisol/stub/stub.rb
CHANGED
data/lib/poisol/stubs.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
module Stubs
|
2
2
|
extend self
|
3
3
|
|
4
|
+
def all
|
5
|
+
@stubs
|
6
|
+
end
|
7
|
+
|
4
8
|
def add stub
|
5
9
|
@stubs = [] if @stubs.blank?
|
6
10
|
@stubs << stub
|
@@ -35,9 +39,8 @@ module Stubs
|
|
35
39
|
end
|
36
40
|
|
37
41
|
def load_as_json input
|
38
|
-
require 'json'
|
39
42
|
begin
|
40
|
-
return
|
43
|
+
return Parse.json_to_hash input
|
41
44
|
rescue
|
42
45
|
return input
|
43
46
|
end
|
data/lib/poisol/utils/logger.rb
CHANGED
@@ -10,19 +10,19 @@ class PoisolLog
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def error message
|
13
|
-
logger.error "#{message}
|
13
|
+
logger.error "#{message}"
|
14
14
|
end
|
15
15
|
|
16
16
|
def info message
|
17
|
-
logger.info "#{message}
|
17
|
+
logger.info "#{message}"
|
18
18
|
end
|
19
19
|
|
20
20
|
def warn message
|
21
|
-
logger.warn "#{message}
|
21
|
+
logger.warn "#{message}"
|
22
22
|
end
|
23
23
|
|
24
24
|
def debug message
|
25
|
-
logger.debug "#{message}
|
25
|
+
logger.debug "#{message}"
|
26
26
|
end
|
27
27
|
|
28
28
|
end
|
data/lib/poisol.rb
CHANGED
@@ -7,25 +7,19 @@ module Poisol
|
|
7
7
|
|
8
8
|
def start (param={:at_port=>3030})
|
9
9
|
Server.start param[:at_port]
|
10
|
-
|
10
|
+
reset_data
|
11
11
|
end
|
12
12
|
|
13
13
|
def load folder
|
14
14
|
StubFactory.new.build folder
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def reset_data
|
18
18
|
Stubs.reset
|
19
19
|
end
|
20
20
|
|
21
21
|
def stop
|
22
22
|
Server.stop
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
def log_all_calls to_domain
|
27
|
-
if req_signature.to_s.include? to_domain
|
28
|
-
PoisolLog.info "========================\nRequest\n#{req_signature.uri}\n#{req_signature.body}\nResponse:#{response.status[0]}\n#{JSON.pretty_generate(JSON.parse(response.body)) if response.status.present?}"
|
29
|
-
end
|
23
|
+
reset_data
|
30
24
|
end
|
31
25
|
end
|
data/spec/spec_helper.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Deepak
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
description:
|
125
|
+
description: HTTP stub as DSL
|
126
126
|
email:
|
127
127
|
executables: []
|
128
128
|
extensions: []
|
@@ -206,7 +206,7 @@ rubyforge_project:
|
|
206
206
|
rubygems_version: 2.2.2
|
207
207
|
signing_key:
|
208
208
|
specification_version: 4
|
209
|
-
summary:
|
209
|
+
summary: HTTP stub as DSL
|
210
210
|
test_files:
|
211
211
|
- spec/data/domain/first/domain.yml
|
212
212
|
- spec/data/domain/first/first.yml
|