mirage 2.0.0.alpha2 → 2.0.0.alpha3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0.alpha2
1
+ 2.0.0.alpha3
data/bin/mirage CHANGED
@@ -33,7 +33,6 @@ end
33
33
  def stop_mirage
34
34
  mirage_process_ids.each { |process_id| windows? ? `taskkill /F /T /PID #{process_id}` : `kill -9 #{process_id}` }
35
35
  wait_until{ mirage_process_ids.size == 0 }
36
-
37
36
  end
38
37
 
39
38
  if ARGV.include?('start')
@@ -8,7 +8,6 @@ Feature: Mirage is started from the command line.
8
8
  | Usage: mirage start\|stop [options] |
9
9
  | -p, --port PORT |
10
10
  | -d, --defaults DIR |
11
- | --debug |
12
11
 
13
12
 
14
13
  Scenario: Starting with help option
@@ -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
@@ -36,7 +36,7 @@ Given /^Mirage (is|is not) running$/ do |running|
36
36
  if running == 'is'
37
37
  start_mirage unless $mirage.running?
38
38
  else
39
- stop_mirage if $mirage.running?
39
+ stop_mirage if $mirage.running?
40
40
  end
41
41
  end
42
42
 
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.upcase, body, query_string)
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.alpha2
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: 3094995407678883381
216
+ hash: 4414235670568771214
217
217
  segments:
218
218
  - 0
219
219
  version: "0"