faraday-hot_mock 0.6.1 → 0.6.2
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/faraday/hot_mock/version.rb +1 -1
- data/lib/faraday/hot_mock.rb +7 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8404a4aacd47d61fd57da47cc113f0aacaba5ecf503e62241887f7f816914b94
|
|
4
|
+
data.tar.gz: 1b4e147425ffb319a4e162af72555f8780d555b274b0e7c8925c165cc659ed0f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 928f88000b9403ecce898bccdc92d754da669c39be00d29b652dc6ffc6627975a53ecd2f3485eb62aef04b5b2eea2425e12a07cef56e3f2590efe056465c206b
|
|
7
|
+
data.tar.gz: 120492f759010d866e222c5514295ec2d4426b97766fb3d806c47f982b40810ee7aadada1c13a6760425473de85288d95486b2086a5ce12ac0e8c23045b2b6bc
|
data/lib/faraday/hot_mock.rb
CHANGED
|
@@ -72,14 +72,16 @@ module Faraday
|
|
|
72
72
|
mocks.find { |entry| entry["method"].to_s.upcase == method.to_s.upcase && Regexp.new(entry["url_pattern"]).match?(url.to_s) } || false
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
def record(method:, url:, into_scenario: nil)
|
|
75
|
+
def record(method:, headers: {}, url:, body: {}, into_scenario: nil)
|
|
76
76
|
self.scenario = into_scenario if into_scenario.present?
|
|
77
77
|
|
|
78
78
|
return false if mocked?(method:, url:)
|
|
79
79
|
|
|
80
|
-
faraday = Faraday.new
|
|
80
|
+
faraday = Faraday.new(
|
|
81
|
+
headers:,
|
|
82
|
+
)
|
|
81
83
|
|
|
82
|
-
response = faraday.send(method.downcase.to_sym, url)
|
|
84
|
+
response = faraday.send(method.downcase.to_sym, url, body)
|
|
83
85
|
|
|
84
86
|
FileUtils.mkdir_p(hot_mock_dir)
|
|
85
87
|
FileUtils.touch(hot_mock_file)
|
|
@@ -90,7 +92,7 @@ module Faraday
|
|
|
90
92
|
"method" => method.to_s.upcase,
|
|
91
93
|
"url_pattern" => url.to_s,
|
|
92
94
|
"status" => response.status,
|
|
93
|
-
"headers" => response.headers.to_h.merge(HEADERS[:recorded] => Time.now.utc.iso8601),
|
|
95
|
+
"headers" => response.headers.to_h.merge(HEADERS[:recorded] => Time.now.utc.iso8601, HEADERS[:mocked] => "true"),
|
|
94
96
|
"body" => response.body
|
|
95
97
|
}
|
|
96
98
|
|
|
@@ -114,7 +116,7 @@ module Faraday
|
|
|
114
116
|
"method" => method.to_s.upcase,
|
|
115
117
|
"url_pattern" => url.to_s,
|
|
116
118
|
"status" => response.status,
|
|
117
|
-
"headers" => response.headers.to_h.merge(HEADERS[:recorded] => Time.now.utc.iso8601,
|
|
119
|
+
"headers" => response.headers.to_h.merge(HEADERS[:recorded] => Time.now.utc.iso8601, HEADERS[:mocked] => "true"),
|
|
118
120
|
"body" => response.body
|
|
119
121
|
}
|
|
120
122
|
|