mirage 2.0.0.alpha2 → 2.0.0.alpha3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/mirage +0 -1
- data/features/server/command_line_iterface.feature +0 -1
- data/features/server/set.feature +1 -1
- data/features/step_definitions/my_steps.rb +1 -1
- data/lib/mirage/core.rb +2 -2
- data/lib/mirage/mock_responses_collection.rb +3 -2
- data/lib/start_mirage.rb +6 -8
- data/rakefile +8 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.
|
1
|
+
2.0.0.alpha3
|
data/bin/mirage
CHANGED
data/features/server/set.feature
CHANGED
@@ -11,7 +11,7 @@ Feature: Mirage can be configured with responses to be returned with the correct
|
|
11
11
|
delay (optional) = the amount of time in seconds that mirage should wait for before responding (defaults to 0)
|
12
12
|
method (optional) = http method that this response applies to. (defaults to get if not supplied)
|
13
13
|
default (optional) = set whether the reponse can act as a default response, see set_default_response.feature (defaults to false)
|
14
|
-
content-type = Set the content type to be returned
|
14
|
+
content-type (optional) = Set the content type to be returned
|
15
15
|
|
16
16
|
|
17
17
|
Scenario: Setting a response without any selection criteria
|
data/lib/mirage/core.rb
CHANGED
@@ -24,7 +24,7 @@ module Mirage
|
|
24
24
|
['get', 'post', 'delete', 'put'].each do |http_method|
|
25
25
|
send(http_method, '/mirage/responses/*') do |name|
|
26
26
|
body, query_string = Rack::Utils.unescape(request.body.read.to_s), request.env['QUERY_STRING']
|
27
|
-
record = MOCK_RESPONSES.get_response(name, http_method
|
27
|
+
record = MOCK_RESPONSES.get_response(name, http_method, body, query_string)
|
28
28
|
|
29
29
|
return 404 unless record
|
30
30
|
REQUESTS[record.response_id] = body.empty? ? query_string : body
|
@@ -76,7 +76,7 @@ module Mirage
|
|
76
76
|
@responses["#{response.name}#{'/*' if response.default?}: #{pattern} #{delay}"] = response
|
77
77
|
end
|
78
78
|
erb :index
|
79
|
-
end
|
79
|
+
end
|
80
80
|
|
81
81
|
error do
|
82
82
|
erb request.env['sinatra.error'].message
|
@@ -10,8 +10,8 @@ module Mirage
|
|
10
10
|
stored_responses = @responses[response.name]||={}
|
11
11
|
|
12
12
|
stored_responses[response.pattern] ||= {}
|
13
|
-
old_response = stored_responses[response.pattern].delete(response.http_method)
|
14
|
-
stored_responses[response.pattern][response.http_method] = response
|
13
|
+
old_response = stored_responses[response.pattern].delete(response.http_method.upcase)
|
14
|
+
stored_responses[response.pattern][response.http_method.upcase] = response
|
15
15
|
|
16
16
|
|
17
17
|
# Right not an the main id count goes up by one even if the id is not used because the old id is reused from another response
|
@@ -88,6 +88,7 @@ module Mirage
|
|
88
88
|
|
89
89
|
private
|
90
90
|
def find_response(body, query_string, stored_responses, http_method)
|
91
|
+
http_method = http_method.upcase
|
91
92
|
pattern_match = stored_responses.keys.find_all { |pattern| pattern != :basic }.find { |pattern| (body =~ pattern || query_string =~ pattern) }
|
92
93
|
|
93
94
|
if pattern_match
|
data/lib/start_mirage.rb
CHANGED
@@ -10,8 +10,6 @@ require 'mirage/util'
|
|
10
10
|
include Mirage::Util
|
11
11
|
options = parse_options(ARGV)
|
12
12
|
|
13
|
-
$debug = options[:debug]
|
14
|
-
|
15
13
|
module Mirage
|
16
14
|
class MirageServer < Sinatra::Base
|
17
15
|
configure do
|
@@ -20,14 +18,14 @@ module Mirage
|
|
20
18
|
log_file = File.open('mirage.log', 'a')
|
21
19
|
log_file.sync=true
|
22
20
|
use Rack::CommonLogger, log_file
|
23
|
-
|
24
|
-
if $debug
|
25
|
-
require 'sinatra/reloader'
|
26
|
-
register Sinatra::Reloader
|
27
|
-
also_reload "**/*.rb"
|
28
|
-
end
|
29
21
|
set :views, File.dirname(__FILE__) + '/views'
|
30
22
|
end
|
23
|
+
|
24
|
+
configure(:development) do |config|
|
25
|
+
require 'sinatra/reloader'
|
26
|
+
register Sinatra::Reloader
|
27
|
+
config.also_reload "**/*.rb"
|
28
|
+
end
|
31
29
|
end
|
32
30
|
end
|
33
31
|
|
data/rakefile
CHANGED
@@ -50,5 +50,13 @@ task :clean do |task|
|
|
50
50
|
task.reenable
|
51
51
|
end
|
52
52
|
|
53
|
+
task :start do
|
54
|
+
`RACK_ENV='development' && ruby ./bin/mirage start`
|
55
|
+
end
|
56
|
+
|
57
|
+
task :stop do
|
58
|
+
`RACK_ENV='development' && ruby ./bin/mirage stop`
|
59
|
+
end
|
60
|
+
|
53
61
|
|
54
62
|
task :default => [:install,:features,:clean]
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: mirage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 2.0.0.
|
5
|
+
version: 2.0.0.alpha3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Leon Davis
|
@@ -213,7 +213,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
213
213
|
requirements:
|
214
214
|
- - ">="
|
215
215
|
- !ruby/object:Gem::Version
|
216
|
-
hash:
|
216
|
+
hash: 4414235670568771214
|
217
217
|
segments:
|
218
218
|
- 0
|
219
219
|
version: "0"
|