~ubuntu-branches/ubuntu/oneiric/puppet/oneiric-security

« back to all changes in this revision

Viewing changes to vendor/gems/rspec/lib/spec/mocks/spec_methods.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080726154345-1fmgo76b4l72ulvc
ImportĀ upstreamĀ versionĀ 0.24.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
module Spec
 
2
  module Mocks
 
3
    module ExampleMethods
 
4
      include Spec::Mocks::ArgumentConstraintMatchers
 
5
 
 
6
      # Shortcut for creating an instance of Spec::Mocks::Mock.
 
7
      #
 
8
      # +name+ is used for failure reporting, so you should use the
 
9
      # role that the mock is playing in the example.
 
10
      #
 
11
      # +stubs_and_options+ lets you assign options and stub values
 
12
      # at the same time. The only option available is :null_object.
 
13
      # Anything else is treated as a stub value.
 
14
      #
 
15
      # == Examples
 
16
      #
 
17
      #   stub_thing = mock("thing", :a => "A")
 
18
      #   stub_thing.a == "A" => true
 
19
      #
 
20
      #   stub_person = stub("thing", :name => "Joe", :email => "joe@domain.com")
 
21
      #   stub_person.name => "Joe"
 
22
      #   stub_person.email => "joe@domain.com"
 
23
      def mock(name, stubs_and_options={})
 
24
        Spec::Mocks::Mock.new(name, stubs_and_options)
 
25
      end
 
26
      
 
27
      alias :stub :mock
 
28
 
 
29
      # Shortcut for creating a mock object that will return itself in response
 
30
      # to any message it receives that it hasn't been explicitly instructed
 
31
      # to respond to.
 
32
      def stub_everything(name = 'stub')
 
33
        mock(name, :null_object => true)
 
34
      end
 
35
 
 
36
    end
 
37
  end
 
38
end