Sha256: 6e275e217c39ef0880b2e9dedc17529895400293040f5e9881f80445e0cea986

Contents?: true

Size: 851 Bytes

Versions: 7

Compression:

Stored size: 851 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

7 entries across 7 versions & 2 rubygems

Version Path
has_finder-0.1.1 spec/rails/vendor/plugins/rspec/lib/spec/mocks/spec_methods.rb
has_finder-0.1.2 spec/rails/vendor/plugins/rspec/lib/spec/mocks/spec_methods.rb
has_finder-0.1.3 spec/rails/vendor/plugins/rspec/lib/spec/mocks/spec_methods.rb
rspec-1.0.5 lib/spec/mocks/spec_methods.rb
rspec-1.0.6 lib/spec/mocks/spec_methods.rb
rspec-1.0.7 lib/spec/mocks/spec_methods.rb
rspec-1.0.8 lib/spec/mocks/spec_methods.rb