Method: Spec::Mocks::ExampleMethods#double

Defined in:
lib/spec/mocks/example_methods.rb

#double(*args) ⇒ Object

Shortcut for creating an instance of Spec::Mocks::Mock.

name is used for failure reporting, so you should use the role that the double 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

thing = double("thing", :a => "A")
thing.a == "A" => true

person = double("thing", :name => "Joe", :email => "[email protected]")
person.name => "Joe"
person.email => "[email protected]"


23
24
25
# File 'lib/spec/mocks/example_methods.rb', line 23

def double(*args)
  __declare_double('Double', *args)
end