Class: Mocha::Configuration

Inherits:
Object show all
Defined in:
lib/mocha/configuration.rb

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

Class Method Details

.allow(action) ⇒ Object

:call-seq: allow(action)

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.



14
15
16
# File 'lib/mocha/configuration.rb', line 14

def allow(action)
  configuration[action] = :allow
end

.allow?(action) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


18
19
20
# File 'lib/mocha/configuration.rb', line 18

def allow?(action) # :nodoc:
  configuration[action] == :allow
end

.prevent(action) ⇒ Object

:call-seq: prevent(action)

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.



38
39
40
# File 'lib/mocha/configuration.rb', line 38

def prevent(action)
  configuration[action] = :prevent
end

.prevent?(action) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


42
43
44
# File 'lib/mocha/configuration.rb', line 42

def prevent?(action) # :nodoc:
  configuration[action] == :prevent
end

.reset_configurationObject

:nodoc:



46
47
48
# File 'lib/mocha/configuration.rb', line 46

def reset_configuration # :nodoc:
  @configuration = nil
end

.warn_when(action) ⇒ Object

:call-seq: warn_when(action)

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.



26
27
28
# File 'lib/mocha/configuration.rb', line 26

def warn_when(action)
  configuration[action] = :warn
end

.warn_when?(action) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


30
31
32
# File 'lib/mocha/configuration.rb', line 30

def warn_when?(action) # :nodoc:
  configuration[action] == :warn
end