api_sim 4.2.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41575a14132a1b2470aa099534aa545b2adbd0b6
4
- data.tar.gz: 527e676491d88348720564aac06f4933202c3307
3
+ metadata.gz: f25876bf3d2f81e5cf254366d9a06c9af8b35901
4
+ data.tar.gz: 393cfbc364e26110599c9061a4243199fa5cf756
5
5
  SHA512:
6
- metadata.gz: 9d5998dd5a4aaaba866eb5150e501ee8cacda17068fda2220510ac0f166d6e312bd3290dae821449cc8e39fa6a2c1e7f09e12383e2bb557febeafbcf3382a215
7
- data.tar.gz: '092d59402a7599b6da24d2ef9e8f913357d7f76918aa434f395396f456d35d313e24d6b497f818783357157e640068afc6a16b0c5c96f353d9777bf2f765e00e'
6
+ metadata.gz: 2469924022ed478e38dd51ca3877b1c2d971c9bbc5211bf402377a32d6af1fb899af105bc998d615541da320223b06f94a15f733809ad42a0edfaf519b6d7216
7
+ data.tar.gz: c4509486aeb1fd132f185c0d6baa08506e59e37a337a054088114ae0207e75b4484962582b6610600bf3fd807d7b5f7746f5a6707798b2bafcb64e14d29b9dcf
@@ -6,7 +6,7 @@ require 'api_sim/matchers/base_matcher'
6
6
  module ApiSim
7
7
  module Matchers
8
8
  class DynamicRequestMatcher < BaseMatcher
9
- attr_reader :response_generator, :route, :http_method, :default, :matcher
9
+ attr_reader :response_generator, :route, :http_method, :default, :matcher, :query
10
10
 
11
11
  def initialize(http_method:, route:, response_generator:, default: false, matcher: ALWAYS_TRUE_MATCHER)
12
12
  @matcher = matcher
@@ -5,7 +5,7 @@ require 'api_sim/matchers/base_matcher'
5
5
  module ApiSim
6
6
  module Matchers
7
7
  class RequestBodyMatcher < BaseMatcher
8
- attr_reader :http_method, :route, :headers, :response_code, :matcher, :response_body, :default, :schema
8
+ attr_reader :http_method, :route, :headers, :response_code, :matcher, :response_body, :default, :schema, :query
9
9
 
10
10
  def initialize(http_method:, route:, response_code: 200, response_body: '', headers: {}, default: false, body_matches:, schema: nil)
11
11
  @default = default
@@ -5,7 +5,7 @@ require 'api_sim/matchers/base_matcher'
5
5
  module ApiSim
6
6
  module Matchers
7
7
  class StaticRequestMatcher < BaseMatcher
8
- attr_reader :http_method, :route, :headers, :response_code, :matcher, :response_body, :default, :schema
8
+ attr_reader :http_method, :route, :headers, :response_code, :matcher, :response_body, :default, :schema, :query
9
9
 
10
10
  def initialize(**args)
11
11
  @default = args.fetch(:default, false)
@@ -13,14 +13,19 @@ module ApiSim
13
13
  @headers = args.fetch(:headers, {})
14
14
  @response_body = args.fetch(:response_body, '')
15
15
  @response_code = args.fetch(:response_code, 200)
16
- @route = Mustermann.new(args.fetch(:route))
16
+ route, @query = args.fetch(:route).split('?')
17
+ @query ||= args.fetch(:query, '')
18
+ @route = Mustermann.new(route)
17
19
  @http_method = args.fetch(:http_method)
18
20
  @schema = args.fetch(:schema, nil)
19
21
  @request_schema = args.fetch(:request_schema, nil)
20
22
  end
21
23
 
22
24
  def matches?(request)
23
- matches_route_pattern?(request) && request.request_method == http_method && matcher.call(request)
25
+ matches_route_pattern?(request) &&
26
+ (query.empty? ? true : request.query_string == query) &&
27
+ request.request_method == http_method &&
28
+ matcher.call(request)
24
29
  end
25
30
 
26
31
  def overridden!
@@ -13,7 +13,7 @@ module ApiSim
13
13
  def self.dupe_and_reconfigure(old_matcher, overrides)
14
14
  if old_matcher.match_on_body?
15
15
  Matchers::RequestBodyMatcher.new(
16
- route: old_matcher.route,
16
+ route: old_matcher.route.to_s,
17
17
  http_method: old_matcher.http_method,
18
18
  response_code: overrides.fetch(:response_code),
19
19
  headers: overrides.fetch(:headers),
@@ -22,7 +22,8 @@ module ApiSim
22
22
  )
23
23
  else
24
24
  Matchers::StaticRequestMatcher.new(
25
- route: old_matcher.route,
25
+ route: old_matcher.route.to_s,
26
+ query: old_matcher.query.to_s,
26
27
  http_method: old_matcher.http_method,
27
28
  response_code: overrides.fetch(:response_code),
28
29
  headers: overrides.fetch(:headers),
@@ -1,3 +1,3 @@
1
1
  module ApiSim
2
- VERSION = "4.2.0"
2
+ VERSION = "5.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_sim
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Taylor
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-23 00:00:00.000000000 Z
11
+ date: 2017-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  version: '0'
190
190
  requirements: []
191
191
  rubyforge_project:
192
- rubygems_version: 2.6.8
192
+ rubygems_version: 2.5.1
193
193
  signing_key:
194
194
  specification_version: 4
195
195
  summary: A DSL on top of sinatra for building application simulators