]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/lib/spec/mocks/spec_methods.rb
Show whether a trace is public or private in the trace list, so that a user can easil...
[rails.git] / vendor / gems / rspec-1.1.2 / lib / spec / mocks / spec_methods.rb
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