spec/wait_for_spec.rb in cistern-0.11.2.pre2 vs spec/wait_for_spec.rb in cistern-0.11.2

- old
+ new

@@ -1,15 +1,25 @@ require 'spec_helper' -class WaitForModel < Sample::Model +class WaitForService < Cistern::Service + model :wait_for_model, require: false + collection :wait_for_models, require: false + + class Real + def initialize(*args) + end + end +end + +class WaitForService::WaitForModel < Cistern::Model identity :id attribute :name end -class WaitForModels < Sample::Collection - model WaitForModel +class WaitForService::WaitForModels < Cistern::Collection + model WaitForService::WaitForModel def get(identity) self end end @@ -25,21 +35,21 @@ expect { Cistern.wait_for!(0, 0) { false } }.to raise_exception(Cistern::Timeout) end end describe 'Cistern::Model#wait_for!' do - let(:service) { Sample.new } + let(:service) { WaitForService.new } let(:model) { service.wait_for_models.new(identity: 1) } it "should raise if timeout exceeded" do - expect { model.wait_for!(0, 0) { false } }.to raise_exception(Sample::Timeout) + expect { model.wait_for!(0, 0) { false } }.to raise_exception(WaitForService::Timeout) end end describe "WaitForModel#timeout" do - let(:service) { Sample.new } + let(:service) { WaitForService.new } let(:model) { service.wait_for_models.new(identity: 1) } it "should use service-specific timeout in #wait_for" do service.class.timeout = 0.1 service.class.poll_interval = 0 @@ -47,11 +57,11 @@ elapsed = 0 timeout(2) do expect do model.wait_for! { sleep(0.2); elapsed += 0.2; elapsed > 0.2 } - end.to raise_exception(Sample::Timeout) + end.to raise_exception(WaitForService::Timeout) end end it "should favor explicit timeout" do service.class.timeout = 1 @@ -60,9 +70,9 @@ elapsed = 0 timeout(2) do expect do model.wait_for!(0.1) { sleep(0.2); elapsed += 0.2; elapsed > 0.2 } - end.to raise_exception(Sample::Timeout) + end.to raise_exception(WaitForService::Timeout) end end end