Module: RSpec::Mocks::ExampleMethods
- Includes:
- ArgumentMatchers
- Defined in:
- lib/rspec/mocks/spec_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, but use double.
-
#stub(*args) ⇒ Object
Just like double, but use double.
Methods included from ArgumentMatchers
#any_args, #anything, #boolean, #duck_type, #hash_including, #hash_not_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.
39 40 41 |
# File 'lib/rspec/mocks/spec_methods.rb', line 39 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.
Examples
book = double("book", :title => "The RSpec Book")
book.title => "The RSpec Book"
card = double("card", :suit => "Spades", :rank => "A"
card.suit => "Spades"
card.rank => "A"
21 22 23 |
# File 'lib/rspec/mocks/spec_methods.rb', line 21 def double(*args) declare_double('Double', *args) end |
#mock(*args) ⇒ Object
Just like double, but use double
26 27 28 |
# File 'lib/rspec/mocks/spec_methods.rb', line 26 def mock(*args) declare_double('Mock', *args) end |
#stub(*args) ⇒ Object
Just like double, but use double
31 32 33 |
# File 'lib/rspec/mocks/spec_methods.rb', line 31 def stub(*args) declare_double('Stub', *args) end |