spec/client/runner_spec.rb in mirage-3.0.0.alpha.17 vs spec/client/runner_spec.rb in mirage-3.0.0
- old
+ new
@@ -4,11 +4,11 @@
describe Mirage do
describe 'starting' do
before(:each) do
- @runner = mock
+ @runner = double
Runner.should_receive(:new).and_return(@runner)
end
it 'should start Mirage on port 7001 by default' do
@runner.should_receive(:invoke).with(:start, [], {:port => 7001})
@@ -23,11 +23,11 @@
end
end
describe 'stopping' do
before(:each) do
- @runner = mock
+ @runner = double
Runner.stub(:new).and_return(@runner)
end
it 'should supply single port argument in an array to the runner' do
port = 7001
@@ -49,15 +49,16 @@
it 'should stop the running instance of Mirage' do
options = {:port => []}
runner = Mirage::Runner.new
runner.options = options
- runner.should_receive(:mirage_process_ids).with([]).any_number_of_times.and_return({"7001" => "18901"})
+ runner.stub(:mirage_process_ids).with([]).and_return({"7001" => "18901"})
+
runner.should_receive(:kill).with("18901") do
- runner.rspec_reset
- runner.should_receive(:mirage_process_ids).with([]).any_number_of_times.and_return({})
+ RSpec.reset
+ runner.stub(:mirage_process_ids).with([]).and_return({})
end
Mirage::Runner.should_receive(:new).and_return(runner)
runner.invoke(:stop, [], options)
end
@@ -65,26 +66,26 @@
it 'should not stop any instances when more than one is running' do
options = {:port => []}
runner = Mirage::Runner.new
runner.options = options
- runner.should_receive(:mirage_process_ids).with([]).any_number_of_times.and_return({"7001" => "18901", "7002" => "18902", "7003" => "18903"})
+ runner.stub(:mirage_process_ids).with([]).and_return({"7001" => "18901", "7002" => "18902", "7003" => "18903"})
runner.should_not_receive(:kill)
Mirage::Runner.should_receive(:new).and_return(runner)
- expect { runner.invoke(:stop, [], options) }.to raise_error(Mirage::ClientError)
+ expect{ runner.invoke(:stop, [], options) }.to raise_error(Mirage::ClientError)
end
it 'should stop the instance running on the given port' do
options = {:port => [7001]}
runner = Mirage::Runner.new
runner.options = options
runner.should_receive(:mirage_process_ids).with([7001]).and_return({"7001" => "18901"})
runner.should_receive(:kill).with("18901") do
- runner.rspec_reset
+ RSpec.reset
runner.stub(:mirage_process_ids).with([7001]).and_return({})
end
Mirage::Runner.should_receive(:new).and_return(runner)
runner.invoke(:stop, [], options)
@@ -96,11 +97,11 @@
runner.options = options
runner.should_receive(:mirage_process_ids).with([7001, 7002]).and_return({"7001" => "18901", "7002" => "18902"})
runner.should_receive(:kill).with("18901")
runner.should_receive(:kill).with("18902") do
- runner.rspec_reset
+ RSpec.reset
runner.stub(:mirage_process_ids).with([7001, 7002]).and_return({})
end
Mirage::Runner.should_receive(:new).and_return(runner)
runner.invoke(:stop, [], options)
@@ -112,11 +113,11 @@
runner.options = options
runner.should_receive(:mirage_process_ids).with([:all]).and_return({"7001" => "18901", "7002" => "18902"})
runner.should_receive(:kill).with("18901")
runner.should_receive(:kill).with("18902") do
- runner.rspec_reset
+ RSpec.reset
runner.stub(:mirage_process_ids).with([:all]).and_return({})
end
Mirage::Runner.should_receive(:new).and_return(runner)
runner.invoke(:stop, [], options)
@@ -125,13 +126,13 @@
it 'should not error when asked to stop Mirage on a port that it is not running on' do
options = {:port => [7001]}
runner = Mirage::Runner.new
runner.options = options
- runner.should_receive(:mirage_process_ids).with([7001]).any_number_of_times.and_return({})
+ runner.stub(:mirage_process_ids).with([7001]).and_return({})
Mirage::Runner.should_receive(:new).and_return(runner)
- expect { runner.invoke(:stop, [], options) }.to_not raise_error(Mirage::ClientError)
+ expect { runner.invoke(:stop, [], options) }.not_to raise_error(Mirage::ClientError)
end
end
end
\ No newline at end of file