class RSpec::Mocks::Configuration
Provides configuration options for rspec-mocks.
def add_stub_and_should_receive_to(*modules)
end
end
mocks.add_stub_and_should_receive_to Delegator
rspec.mock_with :rspec do |mocks|
RSpec.configure do |rspec|
@example
the process.
methods and remove `stub` and `should_receive` in
"strip themselves down" to a bare minimum set of
if you application uses some proxy classes that
modules or classes. This is usually only necessary
Adds `stub` and `should_receive` to the given
def add_stub_and_should_receive_to(*modules) modules.each do |mod| Syntax.enable_should(mod) end end
def before_verifying_doubles(&block)
ref.some_method!
RSpec::Mocks.configuration.before_verifying_doubles do |ref|
@example
Provides a way to perform customisations when verifying doubles.
def before_verifying_doubles(&block) verifying_double_callbacks << block end
def color?
def color? ::RSpec.configuration.color_enabled? end
def color?
Delegates to rspec-core's color option if rspec-core
Indicates whether or not diffs should be colored.
def color? @color end
def initialize
def initialize @yield_receiver_to_any_instance_implementation_blocks = true @verify_doubled_constant_names = false @transfer_nested_constants = false @verify_partial_doubles = false end
def patch_marshal_to_support_partial_doubles=(val)
the patch.
these singleton methods before serialization. Setting to falsey removes
adding singleton methods that cannot be serialized. This patch removes
objects. By default this will not work since RSpec mocks works by
Monkey-patch `Marshal.dump` to enable dumping of mocked or stubbed
def patch_marshal_to_support_partial_doubles=(val) if val RSpec::Mocks::MarshalExtension.patch! else RSpec::Mocks::MarshalExtension.unpatch! end end
def reset_syntaxes_to_default
- Api: - private
def reset_syntaxes_to_default self.syntax = [:should, :expect] RSpec::Mocks::Syntax.warn_about_should! end
def syntax
end
raise "this RSpec extension gem requires the rspec-mocks `:expect` syntax"
unless RSpec::Mocks.configuration.syntax.include?(:expect)
@example
that are enabled.
Returns an array with a list of syntaxes
def syntax syntaxes = [] syntaxes << :should if Syntax.should_enabled? syntaxes << :expect if Syntax.expect_enabled? syntaxes end
def syntax=(*values)
end
end
mocks.syntax = [:expect, :should]
rspec.mock_with :rspec do |mocks|
RSpec.configure do |rspec|
@example
disable `expect` syntax.
explicitly enable `should` syntax and/or explicitly
syntax by default. This is needed if you want to
`should` or both syntaxes. RSpec uses `expect`
Provides the ability to set either `expect`,
def syntax=(*values) syntaxes = values.flatten if syntaxes.include?(:expect) Syntax.enable_expect else Syntax.disable_expect end if syntaxes.include?(:should) Syntax.enable_should else Syntax.disable_should end end
def transfer_nested_constants?
def transfer_nested_constants? !!@transfer_nested_constants end
def verify_doubled_constant_names?
def verify_doubled_constant_names? !!@verify_doubled_constant_names end
def verify_partial_doubles=(val)
doubles. Any stubs will have their arguments checked against the original
When set to true, partial mocks will be verified the same as object
def verify_partial_doubles=(val) @verify_partial_doubles = !!val end
def verify_partial_doubles?
def verify_partial_doubles? @verify_partial_doubles end
def verifying_double_callbacks
- Api: - private
def verifying_double_callbacks @verifying_double_callbacks ||= [] end
def yield_receiver_to_any_instance_implementation_blocks?
def yield_receiver_to_any_instance_implementation_blocks? @yield_receiver_to_any_instance_implementation_blocks end