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
appropriate modules.
RSpec will translate `:rspec`, `:minitest`, and `:test_unit` into the
config.expect_with OtherExpectationFramework
config.expect_with :rspec, :minitest
config.expect_with :minitest
config.expect_with :test_unit
config.expect_with :rspec
module, or any combination thereof:
`frameworks` can be `:rspec`, `:test_unit`, `:minitest`, a custom
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' # Tag this exception class so our exception formatting logic knows # that it satisfies the `MultipleExceptionError` interface. ::RSpec::Expectations::MultipleExpectationsNotMetError.__send__( :include, MultipleExceptionError::InterfaceTag ) ::RSpec::Matchers when :test_unit require 'rspec/core/test_unit_assertions_adapter' ::RSpec::Core::TestUnitAssertionsAdapter when :minitest require 'rspec/core/minitest_assertions_adapter' ::RSpec::Core::MinitestAssertionsAdapter 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