Sha256: a36a6e0ab4233756950cddfcaab41269fbfcb12ff5fa92f50ff5c1b40462d328

Contents?: true

Size: 643 Bytes

Versions: 6

Compression:

Stored size: 643 Bytes

Contents

require 'active_support/core_ext/hash/except'

RSpec::Matchers.define :have_options do |expected|
  match do |actual|
    options == expected
  end

  failure_message do
    msg = "expected to contain options #{expected} but actually contained #{options}\nDiff:"

    differ = RSpec::Support::Differ.new(
        :object_preparer => lambda { |object| RSpec::Matchers::Composable.surface_descriptions_in(object) },
        :color => RSpec::Matchers.configuration.color?
    )

    msg << differ.diff(options, expected)
    msg
  end

  def options
    expected.key?(:controllers) ? actual.options : actual.options.except(:controllers)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
waiter-2.0.5 spec/support/matchers/have_options.rb
waiter-2.0.4 spec/support/matchers/have_options.rb
waiter-2.0.3 spec/support/matchers/have_options.rb
waiter-2.0.2 spec/support/matchers/have_options.rb
waiter-2.0.1 spec/support/matchers/have_options.rb
waiter-2.0.0 spec/support/matchers/have_options.rb