Class: RSpec::Expectations::Configuration
- Inherits:
-
Object
- Object
- RSpec::Expectations::Configuration
- Defined in:
- lib/rspec/expectations/configuration.rb
Overview
Provides configuration options for rspec-expectations.
Constant Summary
- NullBacktraceFormatter =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Module.new do def self.format_backtrace(backtrace) backtrace end end
Instance Attribute Summary (collapse)
- - (Object) backtrace_formatter
-
- (Object) color
writeonly
Sets the attribute color.
Instance Method Summary (collapse)
-
- (Object) add_should_and_should_not_to(*modules)
Adds
should
andshould_not
to the given classes or modules. - - (Boolean) color?
-
- (Array<Symbol>) syntax
The list of configured syntaxes.
-
- (Object) syntax=(values)
Configures the supported syntax.
Instance Attribute Details
- (Object) backtrace_formatter
82 83 84 85 86 87 88 |
# File 'lib/rspec/expectations/configuration.rb', line 82 def backtrace_formatter @backtrace_formatter ||= if defined?(::RSpec::Core::BacktraceFormatter) ::RSpec::Core::BacktraceFormatter else NullBacktraceFormatter end end |
- (Object) color=(value) (writeonly)
Sets the attribute color
49 50 51 |
# File 'lib/rspec/expectations/configuration.rb', line 49 def color=(value) @color = value end |
Instance Method Details
- (Object) add_should_and_should_not_to(*modules)
Adds should
and should_not
to the given classes
or modules. This can be used to ensure should
works
properly on things like proxy objects (particular
Delegator
-subclassed objects on 1.8).
62 63 64 65 66 |
# File 'lib/rspec/expectations/configuration.rb', line 62 def add_should_and_should_not_to(*modules) modules.each do |mod| Expectations::Syntax.enable_should(mod) end end |
- (Boolean) color?
45 46 47 |
# File 'lib/rspec/expectations/configuration.rb', line 45 def color? ::RSpec.configuration.color_enabled? end |
- (Array<Symbol>) syntax
The list of configured syntaxes.
35 36 37 38 39 40 |
# File 'lib/rspec/expectations/configuration.rb', line 35 def syntax syntaxes = [] syntaxes << :should if Expectations::Syntax.should_enabled? syntaxes << :expect if Expectations::Syntax.expect_enabled? syntaxes end |
- (Object) syntax=(values)
Configures the supported syntax.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rspec/expectations/configuration.rb', line 19 def syntax=(values) if Array(values).include?(:expect) Expectations::Syntax.enable_expect else Expectations::Syntax.disable_expect end if Array(values).include?(:should) Expectations::Syntax.enable_should else Expectations::Syntax.disable_should end end |