mirage 3.0.0.alpha.17 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -0
- data/Gemfile.lock +107 -76
- data/README.md +2 -1
- data/{rakefile → Rakefile} +0 -0
- data/VERSION +1 -1
- data/features/.nav +10 -0
- data/features/client/clear.feature +5 -3
- data/features/client/configure.feature +4 -2
- data/features/client/model.feature +95 -0
- data/features/client/preview_responses.feature +7 -6
- data/features/client/prime.feature +32 -0
- data/features/client/put.feature +14 -43
- data/features/client/readme.md +3 -0
- data/features/client/requests.feature +3 -1
- data/features/client/running.feature +4 -2
- data/features/client/save_and_revert.feature +5 -3
- data/features/client/start.feature +3 -1
- data/features/client/stop.feature +3 -1
- data/features/commandline_interface/help.feature +1 -1
- data/features/prime.feature +5 -5
- data/features/step_definitions/my_steps.rb +3 -0
- data/features/templates/preview.feature +2 -2
- data/features/templates/put_with_substitutions.feature +1 -1
- data/features/templates/readme.md +0 -3
- data/features/web_user_interface.feature +39 -27
- data/lib/mirage/client/client.rb +0 -1
- data/lib/mirage/client/error.rb +2 -2
- data/lib/mirage/client/runner.rb +1 -1
- data/lib/mirage/client/template.rb +1 -1
- data/lib/mirage/client/templates.rb +1 -1
- data/mirage.gemspec +12 -11
- data/server/extensions/hash.rb +1 -1
- data/spec/client/cli_bridge_spec.rb +2 -2
- data/spec/client/client_spec.rb +4 -4
- data/spec/client/runner_spec.rb +13 -12
- data/spec/client/template/model/instance_methods_spec.rb +1 -1
- data/spec/client/template_spec.rb +1 -1
- data/spec/client/templates_spec.rb +7 -7
- data/spec/server/server_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -3
- data/{responses/default_responses.rb → todo.list} +0 -0
- metadata +14 -13
- data/.rvmrc +0 -1
- data/profiles.rb +0 -1
- data/test.html +0 -12
- data/test.rb +0 -5
- data/todo.lst +0 -2
data/server/extensions/hash.rb
CHANGED
@@ -14,11 +14,11 @@ describe CLIBridge do
|
|
14
14
|
Hashie::Mash.new({
|
15
15
|
:windows => {
|
16
16
|
:kill_string => "taskkill /F /T /PID %d",
|
17
|
-
:set_ps_cmd_expectation => proc{bridge.
|
17
|
+
:set_ps_cmd_expectation => proc{bridge.stub(:`).with(/tasklist.*/).and_return(tasklist_output)}
|
18
18
|
},
|
19
19
|
:linux => {
|
20
20
|
:kill_string => "kill -9 %d",
|
21
|
-
:set_ps_cmd_expectation => proc{IO.
|
21
|
+
:set_ps_cmd_expectation => proc{IO.stub(:popen).with(/ps aux.*/).and_return(tasklist_output)}
|
22
22
|
}
|
23
23
|
})
|
24
24
|
end
|
data/spec/client/client_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe Mirage::Client do
|
|
5
5
|
|
6
6
|
|
7
7
|
before :each do
|
8
|
-
@response =
|
8
|
+
@response = double('response').as_null_object
|
9
9
|
end
|
10
10
|
|
11
11
|
describe 'configuration' do
|
@@ -63,7 +63,7 @@ describe Mirage::Client do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'should clear mirage' do
|
66
|
-
templates_mock =
|
66
|
+
templates_mock = double('templates')
|
67
67
|
Templates.should_receive(:new).and_return(templates_mock)
|
68
68
|
templates_mock.should_receive(:delete_all)
|
69
69
|
Client.new.clear
|
@@ -93,7 +93,7 @@ describe Mirage::Client do
|
|
93
93
|
it 'should find a template' do
|
94
94
|
id = 1
|
95
95
|
mirage = Client.new
|
96
|
-
mock_template =
|
96
|
+
mock_template = double('template')
|
97
97
|
Template.should_receive(:get).with("#{mirage.url}/templates/#{id}").and_return(mock_template)
|
98
98
|
mirage.templates(1).should == mock_template
|
99
99
|
end
|
@@ -103,7 +103,7 @@ describe Mirage::Client do
|
|
103
103
|
it "should put a response on mirage by passing args on to template's put method " do
|
104
104
|
endpoint, value, block = 'greeting', 'hello', Proc.new{}
|
105
105
|
|
106
|
-
templates_mock =
|
106
|
+
templates_mock = double('templates')
|
107
107
|
Templates.should_receive(:new).and_return(templates_mock)
|
108
108
|
|
109
109
|
templates_mock.should_receive(:put).with(endpoint, value, &block)
|
data/spec/client/runner_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe Mirage do
|
|
6
6
|
|
7
7
|
describe 'starting' do
|
8
8
|
before(:each) do
|
9
|
-
@runner =
|
9
|
+
@runner = double
|
10
10
|
Runner.should_receive(:new).and_return(@runner)
|
11
11
|
end
|
12
12
|
|
@@ -25,7 +25,7 @@ describe Mirage do
|
|
25
25
|
|
26
26
|
describe 'stopping' do
|
27
27
|
before(:each) do
|
28
|
-
@runner =
|
28
|
+
@runner = double
|
29
29
|
Runner.stub(:new).and_return(@runner)
|
30
30
|
end
|
31
31
|
|
@@ -51,11 +51,12 @@ describe Mirage do
|
|
51
51
|
runner = Mirage::Runner.new
|
52
52
|
runner.options = options
|
53
53
|
|
54
|
-
runner.
|
54
|
+
runner.stub(:mirage_process_ids).with([]).and_return({"7001" => "18901"})
|
55
|
+
|
55
56
|
|
56
57
|
runner.should_receive(:kill).with("18901") do
|
57
|
-
|
58
|
-
runner.
|
58
|
+
RSpec.reset
|
59
|
+
runner.stub(:mirage_process_ids).with([]).and_return({})
|
59
60
|
end
|
60
61
|
|
61
62
|
Mirage::Runner.should_receive(:new).and_return(runner)
|
@@ -67,11 +68,11 @@ describe Mirage do
|
|
67
68
|
runner = Mirage::Runner.new
|
68
69
|
runner.options = options
|
69
70
|
|
70
|
-
runner.
|
71
|
+
runner.stub(:mirage_process_ids).with([]).and_return({"7001" => "18901", "7002" => "18902", "7003" => "18903"})
|
71
72
|
runner.should_not_receive(:kill)
|
72
73
|
Mirage::Runner.should_receive(:new).and_return(runner)
|
73
74
|
|
74
|
-
expect
|
75
|
+
expect{ runner.invoke(:stop, [], options) }.to raise_error(Mirage::ClientError)
|
75
76
|
end
|
76
77
|
|
77
78
|
|
@@ -82,7 +83,7 @@ describe Mirage do
|
|
82
83
|
|
83
84
|
runner.should_receive(:mirage_process_ids).with([7001]).and_return({"7001" => "18901"})
|
84
85
|
runner.should_receive(:kill).with("18901") do
|
85
|
-
|
86
|
+
RSpec.reset
|
86
87
|
runner.stub(:mirage_process_ids).with([7001]).and_return({})
|
87
88
|
end
|
88
89
|
|
@@ -98,7 +99,7 @@ describe Mirage do
|
|
98
99
|
runner.should_receive(:mirage_process_ids).with([7001, 7002]).and_return({"7001" => "18901", "7002" => "18902"})
|
99
100
|
runner.should_receive(:kill).with("18901")
|
100
101
|
runner.should_receive(:kill).with("18902") do
|
101
|
-
|
102
|
+
RSpec.reset
|
102
103
|
runner.stub(:mirage_process_ids).with([7001, 7002]).and_return({})
|
103
104
|
end
|
104
105
|
|
@@ -114,7 +115,7 @@ describe Mirage do
|
|
114
115
|
runner.should_receive(:mirage_process_ids).with([:all]).and_return({"7001" => "18901", "7002" => "18902"})
|
115
116
|
runner.should_receive(:kill).with("18901")
|
116
117
|
runner.should_receive(:kill).with("18902") do
|
117
|
-
|
118
|
+
RSpec.reset
|
118
119
|
runner.stub(:mirage_process_ids).with([:all]).and_return({})
|
119
120
|
end
|
120
121
|
|
@@ -127,10 +128,10 @@ describe Mirage do
|
|
127
128
|
options = {:port => [7001]}
|
128
129
|
runner = Mirage::Runner.new
|
129
130
|
runner.options = options
|
130
|
-
runner.
|
131
|
+
runner.stub(:mirage_process_ids).with([7001]).and_return({})
|
131
132
|
|
132
133
|
Mirage::Runner.should_receive(:new).and_return(runner)
|
133
|
-
expect { runner.invoke(:stop, [], options) }.
|
134
|
+
expect { runner.invoke(:stop, [], options) }.not_to raise_error(Mirage::ClientError)
|
134
135
|
end
|
135
136
|
|
136
137
|
end
|
@@ -137,7 +137,7 @@ describe Template::Model::InstanceMethods do
|
|
137
137
|
|
138
138
|
describe 'response as default' do
|
139
139
|
it 'should be false by default' do
|
140
|
-
JSON.parse(instance.to_json)[
|
140
|
+
JSON.parse(instance.to_json, symbolize_names: true)[:response][:default].should == false
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'should set the default value' do
|
@@ -69,7 +69,7 @@ describe Mirage::Template do
|
|
69
69
|
template_url = 'url'
|
70
70
|
response = mock(code: 404)
|
71
71
|
Template.should_receive(:backedup_get).with(template_url, :format => :json).and_return response
|
72
|
-
expect{Template.get(template_url)}.to raise_error Mirage::
|
72
|
+
expect{Template.get(template_url)}.to raise_error Mirage::TemplateNotFound
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -7,7 +7,7 @@ describe 'templates' do
|
|
7
7
|
describe 'deleting' do
|
8
8
|
it 'should delete all templates and associated request data' do
|
9
9
|
base_url = "base_url"
|
10
|
-
requests =
|
10
|
+
requests = double('requests')
|
11
11
|
Requests.should_receive(:new).with(base_url).and_return(requests)
|
12
12
|
|
13
13
|
Templates.should_receive(:delete).with("#{base_url}/templates")
|
@@ -111,11 +111,11 @@ describe 'templates' do
|
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'should prepend base url to the endpoint unless it is set already' do
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
114
|
+
original_template = model_class.new
|
115
|
+
stored_template = @templates.put original_template
|
116
|
+
stored_template.endpoint.should == "#{@base_url}/templates/#{endpoint}"
|
117
|
+
stored_template = @templates.put original_template
|
118
|
+
stored_template.endpoint.should == "#{@base_url}/templates/#{endpoint}"
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'should fall over to methods on the caller if the method does not exist on the template object' do
|
@@ -159,7 +159,7 @@ describe 'templates' do
|
|
159
159
|
@base_url = "base_url"
|
160
160
|
@templates = Templates.new(@base_url)
|
161
161
|
|
162
|
-
@template_mock =
|
162
|
+
@template_mock = double('template')
|
163
163
|
Template.should_receive(:new).with("#{@base_url}/templates/#{endpoint}", value, @templates.default_config).and_return(@template_mock)
|
164
164
|
@template_mock.should_receive(:create)
|
165
165
|
end
|
data/spec/server/server_spec.rb
CHANGED
@@ -70,7 +70,7 @@ describe "Mirage Server" do
|
|
70
70
|
it 'should use headers' do
|
71
71
|
headers = {"HEADER" => 'VALUE'}
|
72
72
|
application_expectations do |app|
|
73
|
-
app.
|
73
|
+
app.stub(:env).and_return(headers)
|
74
74
|
app.should_receive(:extract_http_headers).with(headers).and_return(headers)
|
75
75
|
end
|
76
76
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
ROOT_DIR = "#{File.dirname(__FILE__)}/.."
|
2
2
|
$LOAD_PATH.unshift "#{ROOT_DIR}/lib"
|
3
3
|
$LOAD_PATH.unshift "#{ROOT_DIR}/server"
|
4
|
-
require 'simplecov' if ENV['coverage']
|
4
|
+
require 'simplecov' if ENV['coverage'] && RUBY_PLATFORM != 'java'
|
5
5
|
require 'mirage/client'
|
6
6
|
require 'rspec'
|
7
7
|
require 'json'
|
@@ -24,7 +24,7 @@ shared_context :windows do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
before :each do
|
27
|
-
ChildProcess.
|
27
|
+
ChildProcess.stub(:windows?).and_return(true)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -34,7 +34,7 @@ shared_context :linux do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
before :each do
|
37
|
-
ChildProcess.
|
37
|
+
ChildProcess.stub(:windows?).and_return(false)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
shared_context :resources do
|
File without changes
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mirage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0
|
5
|
-
prerelease:
|
4
|
+
version: 3.0.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Leon Davis
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
@@ -245,19 +245,25 @@ extensions: []
|
|
245
245
|
extra_rdoc_files:
|
246
246
|
- README.md
|
247
247
|
files:
|
248
|
-
- .
|
248
|
+
- .ruby-gemset
|
249
|
+
- .ruby-version
|
249
250
|
- .simplecov
|
251
|
+
- .travis.yml
|
250
252
|
- Gemfile
|
251
253
|
- Gemfile.lock
|
252
254
|
- HISTORY
|
253
255
|
- README.md
|
256
|
+
- Rakefile
|
254
257
|
- VERSION
|
255
258
|
- bin/mirage
|
256
259
|
- features/.nav
|
257
260
|
- features/client/clear.feature
|
258
261
|
- features/client/configure.feature
|
262
|
+
- features/client/model.feature
|
259
263
|
- features/client/preview_responses.feature
|
264
|
+
- features/client/prime.feature
|
260
265
|
- features/client/put.feature
|
266
|
+
- features/client/readme.md
|
261
267
|
- features/client/requests.feature
|
262
268
|
- features/client/running.feature
|
263
269
|
- features/client/save_and_revert.feature
|
@@ -305,9 +311,6 @@ files:
|
|
305
311
|
- lib/mirage/client/templates.rb
|
306
312
|
- mirage.gemspec
|
307
313
|
- mirage_server.rb
|
308
|
-
- profiles.rb
|
309
|
-
- rakefile
|
310
|
-
- responses/default_responses.rb
|
311
314
|
- server/app.rb
|
312
315
|
- server/binary_data_checker.rb
|
313
316
|
- server/extensions/hash.rb
|
@@ -333,9 +336,7 @@ files:
|
|
333
336
|
- spec/server/mock_response_spec.rb
|
334
337
|
- spec/server/server_spec.rb
|
335
338
|
- spec/spec_helper.rb
|
336
|
-
-
|
337
|
-
- test.rb
|
338
|
-
- todo.lst
|
339
|
+
- todo.list
|
339
340
|
- views/index.haml
|
340
341
|
- views/response.haml
|
341
342
|
homepage: https://github.com/lashd/mirage
|
@@ -355,13 +356,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
355
356
|
version: '0'
|
356
357
|
segments:
|
357
358
|
- 0
|
358
|
-
hash: -
|
359
|
+
hash: -1516076441970440795
|
359
360
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
360
361
|
none: false
|
361
362
|
requirements:
|
362
|
-
- - ! '
|
363
|
+
- - ! '>='
|
363
364
|
- !ruby/object:Gem::Version
|
364
|
-
version:
|
365
|
+
version: '0'
|
365
366
|
requirements: []
|
366
367
|
rubyforge_project:
|
367
368
|
rubygems_version: 1.8.25
|
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm --create use 1.9.3@mirage
|
data/profiles.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Profile.create
|
data/test.html
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
<HTML>
|
2
|
-
<HEAD><TITLE>Internal Server Error</TITLE></HEAD>
|
3
|
-
<BODY>
|
4
|
-
<H1>Internal Server Error</H1>
|
5
|
-
invalid %-encoding (\n","status":200,"default":false,"content_type":"text/plain"},"request":{"parameters":{},"headers":{"custom-header":"%r{.eon}"},"body_content":[],"http_method":"get"},"delay":0})
|
6
|
-
<HR>
|
7
|
-
<ADDRESS>
|
8
|
-
WEBrick/1.3.1 (Ruby/1.9.2/2012-04-20) at
|
9
|
-
localhost:7001
|
10
|
-
</ADDRESS>
|
11
|
-
</BODY>
|
12
|
-
</HTML>
|
data/test.rb
DELETED
data/todo.lst
DELETED