Class: RSpec::Mocks::Configuration
- Inherits:
-
Object
- Object
- RSpec::Mocks::Configuration
- Defined in:
- lib/rspec/mocks/configuration.rb
Overview
Provides configuration options for rspec-mocks.
Instance Method Summary collapse
-
#add_stub_and_should_receive_to(*modules) ⇒ Object
Adds
stubandshould_receiveto the given modules or classes. -
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #marshal_patched? ⇒ Boolean
- #patch_marshal_to_support_partial_doubles=(val) ⇒ Object
- #should_warn_about_any_instance_blocks? ⇒ Boolean
- #syntax ⇒ Object
- #syntax=(values) ⇒ Object
- #yield_receiver_to_any_instance_implementation_blocks=(arg) ⇒ Object
- #yield_receiver_to_any_instance_implementation_blocks? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
6 7 8 9 10 |
# File 'lib/rspec/mocks/configuration.rb', line 6 def initialize @yield_receiver_to_any_instance_implementation_blocks = false @should_warn_about_any_instance_blocks = true @marshal_patched = false end |
Instance Method Details
#add_stub_and_should_receive_to(*modules) ⇒ Object
Adds stub and should_receive to the given
modules or classes. This is usually only necessary
if you application uses some proxy classes that
"strip themselves down" to a bare minimum set of
methods and remove stub and should_receive in
the process.
40 41 42 43 44 |
# File 'lib/rspec/mocks/configuration.rb', line 40 def add_stub_and_should_receive_to(*modules) modules.each do |mod| Syntax.enable_should(mod) end end |
#marshal_patched? ⇒ Boolean
71 72 73 |
# File 'lib/rspec/mocks/configuration.rb', line 71 def marshal_patched? @marshal_patched end |
#patch_marshal_to_support_partial_doubles=(val) ⇒ Object
67 68 69 |
# File 'lib/rspec/mocks/configuration.rb', line 67 def patch_marshal_to_support_partial_doubles=(val) @marshal_patched = val end |
#should_warn_about_any_instance_blocks? ⇒ Boolean
21 22 23 |
# File 'lib/rspec/mocks/configuration.rb', line 21 def should_warn_about_any_instance_blocks? @should_warn_about_any_instance_blocks end |
#syntax ⇒ Object
60 61 62 63 64 65 |
# File 'lib/rspec/mocks/configuration.rb', line 60 def syntax syntaxes = [] syntaxes << :should if Syntax.should_enabled? syntaxes << :expect if Syntax.expect_enabled? syntaxes end |
#syntax=(values) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rspec/mocks/configuration.rb', line 46 def syntax=(values) if Array(values).include?(:expect) Syntax.enable_expect else Syntax.disable_expect end if Array(values).include?(:should) Syntax.enable_should else Syntax.disable_should end end |
#yield_receiver_to_any_instance_implementation_blocks=(arg) ⇒ Object
16 17 18 19 |
# File 'lib/rspec/mocks/configuration.rb', line 16 def yield_receiver_to_any_instance_implementation_blocks=(arg) @should_warn_about_any_instance_blocks = false @yield_receiver_to_any_instance_implementation_blocks = arg end |
#yield_receiver_to_any_instance_implementation_blocks? ⇒ Boolean
12 13 14 |
# File 'lib/rspec/mocks/configuration.rb', line 12 def yield_receiver_to_any_instance_implementation_blocks? @yield_receiver_to_any_instance_implementation_blocks end |