Class: RSpec::Matchers::Configuration
- Inherits:
-
Object
- Object
- RSpec::Matchers::Configuration
- Defined in:
- lib/rspec/matchers/configuration.rb
Overview
Provides configuration options for rspec-expectations.
Constant Summary collapse
- 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
- #backtrace_formatter ⇒ Object
-
#color ⇒ Object
writeonly
Sets the attribute color.
Instance Method Summary collapse
-
#add_should_and_should_not_to(*modules) ⇒ Object
Adds
should
andshould_not
to the given classes or modules. - #color? ⇒ Boolean
-
#syntax ⇒ Array<Symbol>
The list of configured syntaxes.
-
#syntax=(values) ⇒ Object
Configures the supported syntax.
Instance Attribute Details
#backtrace_formatter ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/rspec/matchers/configuration.rb', line 82 def backtrace_formatter @backtrace_formatter ||= if defined?(::RSpec::Core::BacktraceFormatter) ::RSpec::Core::BacktraceFormatter else NullBacktraceFormatter end end |
#color=(value) ⇒ Object (writeonly)
Sets the attribute color
49 50 51 |
# File 'lib/rspec/matchers/configuration.rb', line 49 def color=(value) @color = value end |
Instance Method Details
#add_should_and_should_not_to(*modules) ⇒ Object
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/matchers/configuration.rb', line 62 def add_should_and_should_not_to(*modules) modules.each do |mod| Expectations::Syntax.enable_should(mod) end end |
#color? ⇒ Boolean
45 46 47 |
# File 'lib/rspec/matchers/configuration.rb', line 45 def color? ::RSpec.configuration.color_enabled? end |
#syntax ⇒ Array<Symbol>
The list of configured syntaxes.
35 36 37 38 39 40 |
# File 'lib/rspec/matchers/configuration.rb', line 35 def syntax syntaxes = [] syntaxes << :should if Expectations::Syntax.should_enabled? syntaxes << :expect if Expectations::Syntax.expect_enabled? syntaxes end |
#syntax=(values) ⇒ Object
Configures the supported syntax.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rspec/matchers/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 |