Sha256: 15ffb4ab837c389985987c1c91e77e36666372d5e2d9fc15220a1a3879c12f39
Contents?: true
Size: 1.98 KB
Versions: 3
Compression:
Stored size: 1.98 KB
Contents
require File.dirname(__FILE__) + '/../../spec_helper.rb' module Spec module Mocks describe "TwiceCounts" do before(:each) do @mock = mock("test mock") end it "twice should fail when call count is higher than expected" do @mock.should_receive(:random_call).twice @mock.random_call @mock.random_call @mock.random_call lambda do @mock.rspec_verify end.should raise_error(MockExpectationError) end it "twice should fail when call count is lower than expected" do @mock.should_receive(:random_call).twice @mock.random_call lambda do @mock.rspec_verify end.should raise_error(MockExpectationError) end it "twice should fail when called twice with wrong args on the first call" do @mock.should_receive(:random_call).twice.with("1", 1) lambda do @mock.random_call(1, "1") end.should raise_error(MockExpectationError) @mock.rspec_reset end it "twice should fail when called twice with wrong args on the second call" do @mock.should_receive(:random_call).twice.with("1", 1) @mock.random_call("1", 1) lambda do @mock.random_call(1, "1") end.should raise_error(MockExpectationError) @mock.rspec_reset end it "twice should pass when called twice" do @mock.should_receive(:random_call).twice @mock.random_call @mock.random_call @mock.rspec_verify end it "twice should pass when called twice with specified args" do @mock.should_receive(:random_call).twice.with("1", 1) @mock.random_call("1", 1) @mock.random_call("1", 1) @mock.rspec_verify end it "twice should pass when called twice with unspecified args" do @mock.should_receive(:random_call).twice @mock.random_call("1") @mock.random_call(1) @mock.rspec_verify end end end end
Version data entries
3 entries across 3 versions & 1 rubygems