Module: Hyperion::Kim::Matchers
- Extended by:
- Matchers
- Included in:
- FakeServer, Matchers
- Defined in:
- lib/hyperion_test/kim/matchers.rb
Instance Method Summary collapse
- #req_headers(required_headers) ⇒ Object
- #req_params(required_params) ⇒ Object
-
#res(resource_pattern) ⇒ Object
Some useful matchers to include in your code.
- #verb(verb_to_match) ⇒ Object
Instance Method Details
#req_headers(required_headers) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/hyperion_test/kim/matchers.rb', line 23 def req_headers(required_headers) Matcher.new do |req| required_headers.each_pair.all? do |(k, v)| hash_includes?(req.headers.to_h, k, v) end end end |
#req_params(required_params) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/hyperion_test/kim/matchers.rb', line 31 def req_params(required_params) Matcher.new do |req| required_params.each_pair.all? do |(k, v)| hash_includes?(req.params.to_h, k, v) end end end |
#res(resource_pattern) ⇒ Object
Some useful matchers to include in your code
9 10 11 12 13 14 15 |
# File 'lib/hyperion_test/kim/matchers.rb', line 9 def res(resource_pattern) regex = resource_pattern.gsub(/:([^\/]+)/, "(?<\\1>[^\\/]+)") Matcher.new do |req| m = req.path.match(regex) m && req.merge_params(m.names.zip(m.captures).to_h) end end |