1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/spec/eventually_spec.rb
2009-05-18 23:06:49 -07:00

39 lines
1.3 KiB
Ruby

require File.dirname(__FILE__) + '/../../spec_helper'
describe "should eventually { block }" do
it "should pass if block returns true immediately" do
lambda { true }.should eventually { |expected| expected.should == true }
end
it "should pass if block returns true after a delay" do
eventually = Eventually.new(true, 1)
lambda { true }.should eventually { |expected| expected.should == eventually.test }
end
it "should fail if block returns false despite delay" do
lambda {
lambda { true }.should eventually { |expected| expected.should == false }
}.should raise_error(Spec::Expectations::ExpectationNotMetError)
end
end
describe "should_not eventually { block }" do
it "should pass if block returns false immediately" do
lambda { true }.should_not eventually { |expected| expected.should_not == false }
end
it "should pass if block returns false after a delay" do
eventually = Eventually.new(false, 1)
lambda { true }.should_not eventually { |expected| expected.should_not == eventually.test }
end
it "should fail if block returns true despite delay" do
lambda {
lambda { true }.should_not eventually { |expected| expected.should_not == true }
}.should raise_error(Spec::Expectations::ExpectationNotMetError)
end
end