api_sim 0.1.0 → 1.1.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: 9a955753fef75d629e045f738959d4c4a523e466
4
- data.tar.gz: fa3627d00573c6e0299fcc985738977bc40889bc
3
+ metadata.gz: 3b15c7a6cedd1f3b8c3544986dce19a917911ea9
4
+ data.tar.gz: daaac2cab53393e6ade881e389108d1ff3e15540
5
5
  SHA512:
6
- metadata.gz: 71d6f5e74b37fc3f74e9ddfb45a7cea2804521d1cc52f579746478c3dc0d7c184b49c6625aed3e2880c7fe2b9b97b8d5c2bde529de0b898084469cd81e675961
7
- data.tar.gz: 802e0105bae925cae7a1ca2a4af8ce272238ab3239cd47e3b991dc66482f8bbc85f14f8e474d2a9c8de2aabe3a57a904014b13b172612654f8df5e5d7aa14177
6
+ metadata.gz: 3177ab13b83c0dd6a952a42d8cd9c863e87ac1f235e5c03fbf79788e9c2b1905824e2bf133b5b89e7220e9640a2bada03e8c767cfa4c899d48a73418eb0fd684
7
+ data.tar.gz: f0310976ccd8c1a41e7754034d77083caff7b3b139a441a7516c03a4f1c32abb430fff2e59d1a36acdd7dd9901e7e6755aacf2baa2d2096d7154d99f741f4351
data/config.example.ru CHANGED
@@ -4,6 +4,7 @@ ENDPOINT_JSON_SCHEMA = {"type": "object", "properties": {"a": {"type": "integer"
4
4
 
5
5
  app = ApiSim.build_app do
6
6
  configure_endpoint 'GET', '/endpoint', 'Hi!', 200, {'X-CUSTOM-HEADER' => 'easy as abc'}, ENDPOINT_JSON_SCHEMA
7
+ configure_endpoint 'GET', '/begin/:middle/end', 'You found an any-value path', 200, {'CONTENT-TYPE' => 'application/json'}
7
8
 
8
9
  configure_dynamic_endpoint 'GET', '/dynamic', ->(req) {
9
10
  [201, {'X-CUSTOM-HEADER' => '123'}, 'Howdy!']
@@ -18,7 +18,7 @@ module ApiSim
18
18
  end
19
19
 
20
20
  def matches?(request)
21
- request.path == route && request.request_method == http_method && matcher.call(request)
21
+ matches_dynamic_path?(request) && request.request_method == http_method && matcher.call(request)
22
22
  end
23
23
 
24
24
  def custom_matcher?
@@ -51,6 +51,15 @@ module ApiSim
51
51
  request.body.rewind
52
52
  requests.push(RecordedRequest.new(body: request.body.read, request_env: request.env))
53
53
  end
54
+
55
+ def matches_dynamic_path?(request)
56
+ route_tokens = route.split('/')
57
+ request_tokens = request.path.split('/')
58
+
59
+ route_tokens.zip(request_tokens).all? do |matcher_part, request_part|
60
+ matcher_part == request_part || matcher_part.start_with?(':')
61
+ end
62
+ end
54
63
  end
55
64
  end
56
65
  end
@@ -1,3 +1,3 @@
1
1
  module ApiSim
2
- VERSION = "0.1.0"
2
+ VERSION = "1.1.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: 0.1.0
4
+ version: 1.1.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: 2016-04-28 00:00:00.000000000 Z
11
+ date: 2016-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  requirements: []
166
166
  rubyforge_project:
167
- rubygems_version: 2.5.1
167
+ rubygems_version: 2.5.0
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: A DSL on top of sinatra for building application simulators