mirage 1.3.3 → 1.3.4
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 +1 -1
- data/bin/mirage +20 -24
- data/features/server/command_line_iterface.feature +7 -1
- data/features/support/env.rb +10 -7
- data/lib/mirage/core.rb +1 -2
- data/mirage.gemspec +1 -1
- data/rakefile +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.4
|
data/bin/mirage
CHANGED
@@ -7,49 +7,45 @@ include Mirage::Util
|
|
7
7
|
RUBY_CMD = RUBY_PLATFORM == 'java' ? 'jruby' : 'ruby'
|
8
8
|
|
9
9
|
|
10
|
-
def start_mirage(args
|
10
|
+
def start_mirage(args)
|
11
11
|
puts "Starting Mirage"
|
12
12
|
|
13
13
|
if windows?
|
14
|
-
command = ["cmd", "/C", "start",
|
14
|
+
command = ["cmd", "/C", "start", "\"mirage server\"", RUBY_CMD, "#{File.dirname(__FILE__)}/../lib/start_mirage.rb"]
|
15
15
|
else
|
16
|
-
|
16
|
+
command = [RUBY_CMD, "#{File.dirname(__FILE__)}/../lib/start_mirage.rb"]
|
17
17
|
end
|
18
18
|
ChildProcess.build(*(command.concat(args))).start
|
19
|
-
|
20
|
-
wait_until do
|
21
|
-
mirage.running?
|
22
|
-
end
|
19
|
+
Mirage::Client.new "http://localhost:#{parse_options(ARGV)[:port]}/mirage"
|
23
20
|
end
|
24
21
|
|
25
22
|
|
26
|
-
def
|
23
|
+
def mirage_process_ids
|
27
24
|
if windows?
|
28
|
-
|
29
|
-
`taskkill /F /T /PID #{process_id}` if process_id
|
25
|
+
[`tasklist /V | findstr "mirage\\ server"`.split(' ')[1]].compact
|
30
26
|
else
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
system "kill -9 #{process_id}" if process_id
|
35
|
-
end
|
36
|
-
rescue
|
37
|
-
puts 'Mirage is not running'
|
38
|
-
end
|
27
|
+
["Mirage Server", 'start_mirage'].collect do |process_name|
|
28
|
+
`ps aux | grep "#{process_name}" | grep -v grep`.split(' ')[1]
|
29
|
+
end.find_all { |process_id| process_id != $$.to_s }.compact
|
39
30
|
end
|
40
31
|
end
|
41
32
|
|
42
|
-
|
33
|
+
def stop_mirage
|
34
|
+
mirage_process_ids.each { |process_id| windows? ? `taskkill /F /T /PID #{process_id}` : `kill -9 #{process_id}` }
|
35
|
+
end
|
43
36
|
|
44
|
-
|
45
|
-
mirage_client = Mirage::Client.new "http://localhost:#{options[:port]}/mirage"
|
37
|
+
if ARGV.include?('start')
|
46
38
|
|
47
|
-
|
48
|
-
puts "Mirage already running"
|
39
|
+
unless mirage_process_ids.empty?
|
40
|
+
puts "Mirage is already running"
|
49
41
|
exit 1
|
50
42
|
end
|
51
43
|
|
52
|
-
start_mirage(ARGV
|
44
|
+
mirage_client = start_mirage(ARGV)
|
45
|
+
wait_until do
|
46
|
+
mirage_client.running?
|
47
|
+
end
|
48
|
+
|
53
49
|
begin
|
54
50
|
mirage_client.prime
|
55
51
|
rescue Mirage::InternalServerException => e
|
@@ -36,4 +36,10 @@ Feature: Mirage is started from the command line.
|
|
36
36
|
Scenario: Starting Mirage on a custom port
|
37
37
|
Given Mirage is not running
|
38
38
|
When I run 'mirage start -p 9001'
|
39
|
-
Then mirage should be running on 'http://localhost:9001/mirage'
|
39
|
+
Then mirage should be running on 'http://localhost:9001/mirage'
|
40
|
+
|
41
|
+
Scenario: Starting Mirage when it is already running
|
42
|
+
Given Mirage is running
|
43
|
+
When I run 'mirage start -p 9001'
|
44
|
+
Then I should see 'Mirage is already running' on the command line
|
45
|
+
Then Connection should be refused to 'http://localhost:9001/mirage'
|
data/features/support/env.rb
CHANGED
@@ -5,15 +5,16 @@ require 'cucumber'
|
|
5
5
|
require 'rspec'
|
6
6
|
require 'mechanize'
|
7
7
|
|
8
|
+
include Mirage::Util
|
8
9
|
SCRATCH = './scratch'
|
9
10
|
RUBY_CMD = RUBY_PLATFORM == 'JAVA' ? 'jruby' : 'ruby'
|
11
|
+
BLANK_RUBYOPT_CMD = windows? ? 'set RUBYOPT=' : "export RUBYOPT=''"
|
10
12
|
$log_file_marker = 0
|
11
13
|
|
12
|
-
|
13
14
|
module CommandLine
|
14
15
|
def execute command
|
15
16
|
command_line_output_path = "#{SCRATCH}/commandline_output.txt"
|
16
|
-
system "
|
17
|
+
system "#{BLANK_RUBYOPT_CMD} && cd #{SCRATCH} && #{command} > #{File.basename(command_line_output_path)}"
|
17
18
|
File.read(command_line_output_path)
|
18
19
|
end
|
19
20
|
end
|
@@ -46,11 +47,11 @@ module Regression
|
|
46
47
|
include CommandLine
|
47
48
|
|
48
49
|
def stop_mirage
|
49
|
-
system "
|
50
|
+
system "#{BLANK_RUBYOPT_CMD} && cd #{SCRATCH} && mirage stop"
|
50
51
|
end
|
51
52
|
|
52
53
|
def start_mirage
|
53
|
-
system "
|
54
|
+
system "#{BLANK_RUBYOPT_CMD} && cd #{SCRATCH} && mirage start"
|
54
55
|
end
|
55
56
|
|
56
57
|
def run command
|
@@ -91,11 +92,13 @@ Before do
|
|
91
92
|
end
|
92
93
|
|
93
94
|
Dir["#{SCRATCH}/*"].each do |file|
|
94
|
-
|
95
|
+
FileUtils.rm_rf(file) unless file == "#{SCRATCH}/mirage.log"
|
95
96
|
end
|
96
97
|
|
97
|
-
|
98
|
-
|
98
|
+
if File.exists? "#{SCRATCH}/mirage.log"
|
99
|
+
@mirage_log_file = File.open("#{SCRATCH}/mirage.log")
|
100
|
+
@mirage_log_file.seek(0, IO::SEEK_END)
|
101
|
+
end
|
99
102
|
end
|
100
103
|
|
101
104
|
|
data/lib/mirage/core.rb
CHANGED
@@ -91,7 +91,6 @@ module Mirage
|
|
91
91
|
pattern = request['pattern'] ? /#{request['pattern']}/ : :basic
|
92
92
|
name = args.join('/')
|
93
93
|
is_default = request['default'] == 'true'
|
94
|
-
the_request = request
|
95
94
|
|
96
95
|
response = MockResponse.new(name, response_value, pattern, delay.to_f, is_default)
|
97
96
|
|
@@ -189,7 +188,7 @@ module Mirage
|
|
189
188
|
end
|
190
189
|
|
191
190
|
def delete_response(response_id)
|
192
|
-
RESPONSES.each do |
|
191
|
+
RESPONSES.values.each do |response_set|
|
193
192
|
response_set.each { |key, response| response_set.delete(key) if response.response_id == response_id }
|
194
193
|
end
|
195
194
|
end
|
data/mirage.gemspec
CHANGED
data/rakefile
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: mirage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.3.
|
5
|
+
version: 1.3.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Leon Davis
|
@@ -180,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
180
180
|
requirements:
|
181
181
|
- - ">="
|
182
182
|
- !ruby/object:Gem::Version
|
183
|
-
hash:
|
183
|
+
hash: 2550934964107386131
|
184
184
|
segments:
|
185
185
|
- 0
|
186
186
|
version: "0"
|