Class: Mocha::Configuration
Overview
Configuration settings
Constant Summary collapse
- DEFAULTS =
{ :stubbing_method_unnecessarily => :allow, :stubbing_method_on_non_mock_object => :allow, :stubbing_non_existent_method => :allow, :stubbing_non_public_method => :allow }
Class Method Summary collapse
-
.allow(action, &block) ⇒ Object
:call-seq: allow(action, &block).
-
.allow?(action) ⇒ Boolean
:nodoc:.
-
.prevent(action, &block) ⇒ Object
:call-seq: prevent(action, &block).
-
.prevent?(action) ⇒ Boolean
:nodoc:.
-
.reset_configuration ⇒ Object
:nodoc:.
-
.warn_when(action, &block) ⇒ Object
:call-seq: warn_when(action, &block).
-
.warn_when?(action) ⇒ Boolean
:nodoc:.
Class Method Details
.allow(action, &block) ⇒ Object
:call-seq: allow(action, &block)
Allow the specified action
(as a symbol). The actions
currently available are :stubbing_method_unnecessarily, :stubbing_method_on_non_mock_object, :stubbing_non_existent_method, :stubbing_non_public_method
. If given a block, the configuration for the action will only be changed for the duration of the block, and will then be restored to the previous value.
15 16 17 |
# File 'lib/mocha/configuration.rb', line 15 def allow(action, &block) change_config action, :allow, &block end |
.allow?(action) ⇒ Boolean
:nodoc:
19 20 21 |
# File 'lib/mocha/configuration.rb', line 19 def allow?(action) # :nodoc: configuration[action] == :allow end |
.prevent(action, &block) ⇒ Object
:call-seq: prevent(action, &block)
Raise a StubbingError if the specified action
(as a symbol) is attempted. The actions
currently available are :stubbing_method_unnecessarily, :stubbing_method_on_non_mock_object, :stubbing_non_existent_method, :stubbing_non_public_method
. If given a block, the configuration for the action will only be changed for the duration of the block, and will then be restored to the previous value.
41 42 43 |
# File 'lib/mocha/configuration.rb', line 41 def prevent(action, &block) change_config action, :prevent, &block end |
.prevent?(action) ⇒ Boolean
:nodoc:
45 46 47 |
# File 'lib/mocha/configuration.rb', line 45 def prevent?(action) # :nodoc: configuration[action] == :prevent end |
.reset_configuration ⇒ Object
:nodoc:
49 50 51 |
# File 'lib/mocha/configuration.rb', line 49 def reset_configuration # :nodoc: @configuration = nil end |
.warn_when(action, &block) ⇒ Object
:call-seq: warn_when(action, &block)
Warn if the specified action
(as a symbol) is attempted. The actions
currently available are :stubbing_method_unnecessarily, :stubbing_method_on_non_mock_object, :stubbing_non_existent_method, :stubbing_non_public_method
. If given a block, the configuration for the action will only be changed for the duration of the block, and will then be restored to the previous value.
28 29 30 |
# File 'lib/mocha/configuration.rb', line 28 def warn_when(action, &block) change_config action, :warn, &block end |
.warn_when?(action) ⇒ Boolean
:nodoc:
32 33 34 |
# File 'lib/mocha/configuration.rb', line 32 def warn_when?(action) # :nodoc: configuration[action] == :warn end |