class RSpec::Core::Configuration
def expect_with(*frameworks)
custom_config.custom_setting = true
config.expect_with OtherExpectationFramework do |custom_config|
yield the `configuration` object if given a block:
If the module responds to `configuration`, `expect_with` will
## Configuration
modules.
RSpec will translate `:rspec` and `:stdlib` into the appropriate
config.expect_with OtherExpectationFramework
config.expect_with :rspec, :stdlib
config.expect_with :stdlib
config.expect_with :rspec
combination thereof:
`frameworks` can be `:rspec`, `:stdlib`, a custom module, or any
group.
Sets the expectation framework module(s) to be included in each example
def expect_with(*frameworks) modules = frameworks.map do |framework| case framework when Module framework when :rspec require 'rspec/expectations' self.expecting_with_rspec = true ::RSpec::Matchers when :stdlib require 'test/unit/assertions' ::Test::Unit::Assertions else raise ArgumentError, "#{framework.inspect} is not supported" end end if (modules - @expectation_frameworks).any? assert_no_example_groups_defined(:expect_with) end if block_given? raise "expect_with only accepts a block with a single argument. Call expect_with #{modules.length} times, once with each argument, instead." if modules.length > 1 raise "#{modules.first} must respond to `configuration` so that expect_with can yield it." unless modules.first.respond_to?(:configuration) yield modules.first.configuration end @expectation_frameworks.push(*modules) end