Sha256: 02fcb5682500ea0f5cd8238a4244420823240e9fabf8233f4acbddb574d5205b

Contents?: true

Size: 1.45 KB

Versions: 58

Compression:

Stored size: 1.45 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper.rb'

module Spec
  module Mocks
    describe "a mock acting as a NullObject" do
      before(:each) do
        @mock = Mock.new("null_object", :null_object => true)
      end

      it "should allow explicit expectation" do
        @mock.should_receive(:something)
        @mock.something
      end

      it "should fail verification when explicit exception not met" do
        lambda do
          @mock.should_receive(:something)
          @mock.rspec_verify
        end.should raise_error(MockExpectationError)
      end

      it "should ignore unexpected methods" do
        @mock.random_call("a", "d", "c")
        @mock.rspec_verify
      end

      it "should expected message with different args first" do
        @mock.should_receive(:message).with(:expected_arg)
        @mock.message(:unexpected_arg)
        @mock.message(:expected_arg)
      end

      it "should expected message with different args second" do
        @mock.should_receive(:message).with(:expected_arg)
        @mock.message(:expected_arg)
        @mock.message(:unexpected_arg)
      end
    end

    describe "#null_object?" do
      it "should default to false" do
        obj = mock('anything')
        obj.should_not be_null_object
      end
    end
    
    describe "#as_null_object" do
      it "should set the object to null_object" do
        obj = mock('anything').as_null_object
        obj.should be_null_object
      end
    end
  end
end

Version data entries

58 entries across 58 versions & 10 rubygems

Version Path
dchelimsky-rspec-1.1.10 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.11.1 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.11.2 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.11.3 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.11.4 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.11.5 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.11.6 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.11.7 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.11 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.12 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.99.1 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.99.13 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.99.2 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.99.3 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.99.4 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.99.5 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.99.6 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.99.7 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.99.8 spec/spec/mocks/null_object_mock_spec.rb
dchelimsky-rspec-1.1.99.9 spec/spec/mocks/null_object_mock_spec.rb