Sha256: 5989d5530883faf8a0094cfc012d5cfa7d22c2aaba586993b515cbc33b993ef9
Contents?: true
Size: 1.92 KB
Versions: 6
Compression:
Stored size: 1.92 KB
Contents
require "spec/spec_helper" module RR module Expectations describe TimesCalledExpectation, ' with AtMostMatcher' do it_should_behave_like "RR::Expectations::TimesCalledExpectation" attr_reader :times, :at_most before do @times = 3 @at_most = TimesCalledMatchers::AtMostMatcher.new(times) @expectation = TimesCalledExpectation.new(double, at_most) end describe "#verify!" do it "returns true when times called == times" do 3.times {expectation.attempt!} expectation.verify! end it "raises error when times called < times" do 2.times {expectation.attempt!} expectation.verify! end end describe "#attempt?" do it "returns true when attempted less than expected times" do 2.times {expectation.attempt!} expectation.should be_attempt end it "returns false when attempted expected times" do 3.times {expectation.attempt!} expectation.should_not be_attempt end it "raises error before attempted more than expected times" do 3.times {expectation.attempt!} proc {expectation.attempt!}.should raise_error( Errors::TimesCalledError ) end end describe "#attempt!" do it "fails when times called more than times" do 3.times {expectation.attempt!} proc do expectation.attempt! end.should raise_error(Errors::TimesCalledError, "foobar()\nCalled 4 times.\nExpected at most 3 times.") end it "passes when times called == times" do 3.times {expectation.attempt!} end it "passes when times called < times" do expectation.attempt! end end describe "#terminal?" do it "returns true" do expectation.should be_terminal end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems