Module: RSpec::Mocks::ExampleMethods
- Includes:
- ArgumentMatchers
- Defined in:
- lib/rspec/mocks/example_methods.rb
Instance Method Summary collapse
-
#allow_message_expectations_on_nil ⇒ Object
Disables warning messages about expectations being set on nil.
-
#double(*args) ⇒ Object
Creates an instance of RSpec::Mocks::Mock.
-
#mock(*args) ⇒ Object
Just like double.
-
#stub(*args) ⇒ Object
Just like double.
-
#stub_const(constant_name, value, options = {}) ⇒ Object
Stubs the named constant with the given value.
Methods included from ArgumentMatchers
#any_args, #anything, #boolean, #duck_type, #hash_excluding, #hash_including, #instance_of, #kind_of, #no_args
Instance Method Details
#allow_message_expectations_on_nil ⇒ Object
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.
40 41 42 |
# File 'lib/rspec/mocks/example_methods.rb', line 40 def Proxy. end |
#double(*args) ⇒ Object
Creates an instance of RSpec::Mocks::Mock.
name is used for failure reporting, so you should use the role that
the mock is playing in the example.
Use stubs to declare one or more method stubs in one statement.
21 22 23 |
# File 'lib/rspec/mocks/example_methods.rb', line 21 def double(*args) declare_double('Double', *args) end |
#mock(*args) ⇒ Object
Just like double
26 27 28 |
# File 'lib/rspec/mocks/example_methods.rb', line 26 def mock(*args) declare_double('Mock', *args) end |
#stub(*args) ⇒ Object
Just like double
31 32 33 |
# File 'lib/rspec/mocks/example_methods.rb', line 31 def stub(*args) declare_double('Stub', *args) end |
#stub_const(constant_name, value, options = {}) ⇒ Object
Stubs the named constant with the given value. Like method stubs, the constant will be restored to its original value (or lack of one, if it was undefined) when the example completes.
81 82 83 |
# File 'lib/rspec/mocks/example_methods.rb', line 81 def stub_const(constant_name, value, = {}) ConstantStubber.stub(constant_name, value, ) end |