Sha256: 0350b44b2106930587f2f2c3ac6ddac59a445c72fabc34568f845b0aa6dcc47f

Contents?: true

Size: 1.53 KB

Versions: 34

Compression:

Stored size: 1.53 KB

Contents

module Spec
  module Mocks
    module ExampleMethods
      include Spec::Mocks::ArgumentConstraints

      # Shortcut for creating an instance of Spec::Mocks::Mock.
      #
      # +name+ is used for failure reporting, so you should use the
      # role that the mock is playing in the example.
      #
      # +stubs_and_options+ lets you assign options and stub values
      # at the same time. The only option available is :null_object.
      # Anything else is treated as a stub value.
      #
      # == Examples
      #
      #   stub_thing = mock("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 mock(name, stubs_and_options={})
        Spec::Mocks::Mock.new(name, stubs_and_options)
      end
      
      alias :stub :mock

      # Shortcut for creating a mock object that will return itself in response
      # to any message it receives that it hasn't been explicitly instructed
      # to respond to.
      def stub_everything(name = 'stub')
        mock(name, :null_object => true)
      end
      
      # Disables warning messages about expectations being set on nil.
      #
      # By default warning messages are issued when expectations are set on nil.  This is to 
      # prevent false-positives and to catch potential bugs early on.
      def allow_message_expectations_on_nil
        Proxy.allow_message_expectations_on_nil
      end

    end
  end
end

Version data entries

34 entries across 34 versions & 7 rubygems

Version Path
dchelimsky-rspec-1.1.10 lib/spec/mocks/spec_methods.rb
dchelimsky-rspec-1.1.11.1 lib/spec/mocks/spec_methods.rb
dchelimsky-rspec-1.1.11.2 lib/spec/mocks/spec_methods.rb
dchelimsky-rspec-1.1.11.3 lib/spec/mocks/spec_methods.rb
dchelimsky-rspec-1.1.11.4 lib/spec/mocks/spec_methods.rb
dchelimsky-rspec-1.1.11.5 lib/spec/mocks/spec_methods.rb
dchelimsky-rspec-1.1.11.6 lib/spec/mocks/spec_methods.rb
dchelimsky-rspec-1.1.11.7 lib/spec/mocks/spec_methods.rb
dchelimsky-rspec-1.1.11 lib/spec/mocks/spec_methods.rb
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/lib/spec/mocks/spec_methods.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/lib/spec/mocks/spec_methods.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/lib/spec/mocks/spec_methods.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/lib/spec/mocks/spec_methods.rb
merb-core-1.1.0.rc1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/lib/spec/mocks/spec_methods.rb
merb-core-1.1.0.pre spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/lib/spec/mocks/spec_methods.rb
mack-0.8.2 lib/gems/rspec-1.1.11/lib/spec/mocks/spec_methods.rb
mack-0.8.3.1 lib/gems/rspec-1.1.12/lib/spec/mocks/spec_methods.rb
mack-0.8.3 lib/gems/rspec-1.1.12/lib/spec/mocks/spec_methods.rb
pictrails-0.5.0 vendor/plugins/rspec/lib/spec/mocks/spec_methods.rb
rspec-1.1.10 lib/spec/mocks/spec_methods.rb