mock_server 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,12 +11,12 @@ module MockServer
11
11
  end
12
12
 
13
13
  def call(env)
14
- return @app.call(env) unless $mock_server_options and
15
- $mock_server_options[:routes] and
16
- lazy_match $mock_server_options[:routes], env["PATH_INFO"]
17
-
18
14
  @options.merge!($mock_server_options)
19
15
 
16
+ verbose(env, $mock_server_options) if @options[:verbose]
17
+ return @app.call(env) unless @options[:routes] and
18
+ lazy_match @options[:routes], env["PATH_INFO"]
19
+
20
20
  @request = Rack::Request.new(env)
21
21
  @data = load_data
22
22
 
@@ -11,9 +11,11 @@ module MockServer
11
11
  end
12
12
 
13
13
  def call(env)
14
- return @app.call(env) unless $mock_server_options and
15
- $mock_server_options[:routes] and
16
- lazy_match $mock_server_options[:routes], env["PATH_INFO"]
14
+ @options.merge!($mock_server_options)
15
+
16
+ verbose(env, $mock_server_options) if @options[:verbose]
17
+ return @app.call(env) unless @options[:routes] and
18
+ lazy_match @options[:routes], env["PATH_INFO"]
17
19
 
18
20
  @options.merge!($mock_server_options)
19
21
 
@@ -3,6 +3,13 @@ module MockServer
3
3
 
4
4
  private
5
5
 
6
+ def verbose(env, options)
7
+ if options
8
+ interception = lazy_match(options[:routes], env["PATH_INFO"]) ? "intercepted!" : "NOT intercepted."
9
+ puts %([MockServer] #{env["PATH_INFO"]} was #{interception}"\n)
10
+ end
11
+ end
12
+
6
13
  def lazy_match(strings, path)
7
14
  regexps = strings.map { |str|
8
15
  escaped = Regexp.escape(str)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mock_server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-11-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
16
- requirement: &70278227742740 !ruby/object:Gem::Requirement
16
+ requirement: &70292136050580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70278227742740
24
+ version_requirements: *70292136050580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hashie
27
- requirement: &70278227740740 !ruby/object:Gem::Requirement
27
+ requirement: &70292136049540 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70278227740740
35
+ version_requirements: *70292136049540
36
36
  description:
37
37
  email: unixcharles@gmail.com
38
38
  executables: []