spec/service_spec.rb in linux_admin-0.9.1 vs spec/service_spec.rb in linux_admin-0.9.2
- old
+ new
@@ -1,112 +1,110 @@
-require 'spec_helper'
-
describe LinuxAdmin::Service do
before(:each) do
@service = LinuxAdmin::Service.new 'foo'
end
describe "#running?" do
it "checks service" do
- @service.should_receive(:run).
+ expect(@service).to receive(:run).
with(@service.cmd(:service),
:params => { nil => ['foo', 'status']}).and_return(double(:exit_status => 0))
@service.running?
end
context "service is running" do
it "returns true" do
@service = LinuxAdmin::Service.new :id => :foo
- @service.should_receive(:run).and_return(double(:exit_status => 0))
- @service.should be_running
+ expect(@service).to receive(:run).and_return(double(:exit_status => 0))
+ expect(@service).to be_running
end
end
context "service is not running" do
it "returns false" do
@service = LinuxAdmin::Service.new :id => :foo
- @service.should_receive(:run).and_return(double(:exit_status => 1))
- @service.should_not be_running
+ expect(@service).to receive(:run).and_return(double(:exit_status => 1))
+ expect(@service).not_to be_running
end
end
end
describe "#enable" do
it "enables service" do
- @service.should_receive(:run!).
+ expect(@service).to receive(:run!).
with(@service.cmd(:chkconfig),
:params => { nil => [ 'foo', 'on']})
@service.enable
end
it "returns self" do
- @service.should_receive(:run!) # stub out cmd invocation
- @service.enable.should == @service
+ expect(@service).to receive(:run!) # stub out cmd invocation
+ expect(@service.enable).to eq(@service)
end
end
describe "#disable" do
it "disable service" do
- @service.should_receive(:run!).
+ expect(@service).to receive(:run!).
with(@service.cmd(:chkconfig),
:params => { nil => [ 'foo', 'off']})
@service.disable
end
it "returns self" do
- @service.should_receive(:run!)
- @service.disable.should == @service
+ expect(@service).to receive(:run!)
+ expect(@service.disable).to eq(@service)
end
end
describe "#start" do
it "starts service" do
- @service.should_receive(:run!).
+ expect(@service).to receive(:run!).
with(@service.cmd(:service),
:params => { nil => [ 'foo', 'start']})
@service.start
end
it "returns self" do
- @service.should_receive(:run!)
- @service.start.should == @service
+ expect(@service).to receive(:run!)
+ expect(@service.start).to eq(@service)
end
end
describe "#stop" do
it "stops service" do
- @service.should_receive(:run!).
+ expect(@service).to receive(:run!).
with(@service.cmd(:service),
:params => { nil => [ 'foo', 'stop']})
@service.stop
end
it "returns self" do
- @service.should_receive(:run!)
- @service.stop.should == @service
+ expect(@service).to receive(:run!)
+ expect(@service.stop).to eq(@service)
end
end
describe "#restart" do
it "stops service" do
- @service.should_receive(:run).
+ expect(@service).to receive(:run).
with(@service.cmd(:service),
:params => { nil => [ 'foo', 'restart']}).and_return(double(:exit_status => 0))
@service.restart
end
context "service restart fails" do
it "manually stops/starts service" do
- @service.should_receive(:run).and_return(double(:exit_status => 1))
- @service.should_receive(:stop)
- @service.should_receive(:start)
+ expect(@service).to receive(:run).and_return(double(:exit_status => 1))
+ expect(@service).to receive(:stop)
+ expect(@service).to receive(:start)
@service.restart
end
end
it "returns self" do
- @service.should_receive(:run).and_return(double(:exit_status => 0))
- @service.restart.should == @service
+ expect(@service).to receive(:run).and_return(double(:exit_status => 0))
+ expect(@service.restart).to eq(@service)
end
end
end