Sha256: 58b3f2c35e6d276f6e0043954b816ed5ae10c8a2fb3abaff32b58116e7f58338

Contents?: true

Size: 850 Bytes

Versions: 10

Compression:

Stored size: 850 Bytes

Contents

module Spec
  module Mocks
    module SpecMethods
      include Spec::Mocks::ArgumentConstraintMatchers

      # Shortcut for creating an instance of Spec::Mocks::Mock.
      def mock(name, options={})
        Spec::Mocks::Mock.new(name, options)
      end

      # Shortcut for creating an instance of Spec::Mocks::Mock with
      # predefined method stubs.
      #
      # == Examples
      #
      #   stub_thing = stub("thing", :a => "A")
      #   stub_thing.a == "A" => true
      #
      #   stub_person = stub("thing", :name => "Joe", :email => "joe@domain.com")
      #   stub_person.name => "Joe"
      #   stub_person.email => "joe@domain.com"
      def stub(name, stubs={})
        object_stub = mock(name)
        stubs.each { |key, value| object_stub.stub!(key).and_return(value) }
        object_stub
      end
      
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rspec-0.9.0 lib/spec/mocks/spec_methods.rb
rspec-0.9.1 lib/spec/mocks/spec_methods.rb
rspec-0.9.2 lib/spec/mocks/spec_methods.rb
rspec-0.9.3 lib/spec/mocks/spec_methods.rb
rspec-0.9.4 lib/spec/mocks/spec_methods.rb
rspec-1.0.0 lib/spec/mocks/spec_methods.rb
rspec-1.0.1 lib/spec/mocks/spec_methods.rb
rspec-1.0.2 lib/spec/mocks/spec_methods.rb
rspec-1.0.3 lib/spec/mocks/spec_methods.rb
rspec-1.0.4 lib/spec/mocks/spec_methods.rb