| Class | RSpec::Core::Configuration |
| In: |
lib/rspec/core/configuration.rb
|
| Parent: | Object |
| formatter_class | [W] |
Use this to add custom settings to the RSpec.configuration object.
RSpec.configuration.add_setting :foo
Creates three methods on the configuration object, a setter, a getter, and a predicate:
RSpec.configuration.foo=(value) RSpec.configuration.foo() RSpec.configuration.foo?() # returns !!foo
Intended for extension frameworks like rspec-rails, so they can add config settings that are domain specific. For example:
RSpec.configure do |c|
c.add_setting :use_transactional_fixtures, :default => true
c.add_setting :use_transactional_examples, :alias => :use_transactional_fixtures
end
add_setting takes an optional hash that supports the following keys:
:default => "default value"
This sets the default value for the getter and the predicate (which will return true as long as the value is not false or nil).
:alias => :other_setting
Aliases its setter, getter, and predicate, to those for the other_setting.
E.g. alias_example_to :crazy_slow, :speed => ‘crazy_slow’ defines crazy_slow as an example variant that has the crazy_slow speed option
Define an alias for it_should_behave_like that allows different language (like "it_has_behavior" or "it_behaves_like") to be employed when including shared examples.
alias_it_should_behave_like_to(:it_has_behavior, 'has behavior:')
allows the user to include a shared example group like:
describe Entity do
it_has_behavior 'sortability' do
let(:sortable) { Entity.new }
end
end
which is reported in the output as:
Entity
has behavior: sortability
# sortability examples here