Sha256: 7dd6212f3fb8f3b61bd9ca026812afa8588e6b4787074fa9a99191fadafe22e2
Contents?: true
Size: 1.98 KB
Versions: 9
Compression:
Stored size: 1.98 KB
Contents
require 'spec_helper' module Rspec 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
9 entries across 9 versions & 1 rubygems