Module: Spec::Mocks::SpecMethods
- Includes:
- ArgumentConstraintMatchers
- Defined in:
- lib/spec/mocks/spec_methods.rb
Instance Method Summary collapse
-
#mock(name, options = {}) ⇒ Object
Shortcut for creating an instance of Spec::Mocks::Mock.
-
#stub(name, stubs = {}) ⇒ Object
Shortcut for creating an instance of Spec::Mocks::Mock with predefined method stubs.
Methods included from ArgumentConstraintMatchers
#any_args, #anything, #boolean, #duck_type, #no_args
Instance Method Details
#mock(name, options = {}) ⇒ Object
Shortcut for creating an instance of Spec::Mocks::Mock.
7 8 9 |
# File 'lib/spec/mocks/spec_methods.rb', line 7 def mock(name, ={}) Spec::Mocks::Mock.new(name, ) end |
#stub(name, stubs = {}) ⇒ Object
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 => "[email protected]")
stub_person.name => "Joe"
stub_person.email => "[email protected]"
22 23 24 25 26 |
# File 'lib/spec/mocks/spec_methods.rb', line 22 def stub(name, stubs={}) object_stub = mock(name) stubs.each { |key, value| object_stub.stub!(key).and_return(value) } object_stub end |