Sha256: e82df1d90f3c9fb06b8024a6d4645cdbac7bb62ea616903adbd0707ed770be8d

Contents?: true

Size: 935 Bytes

Versions: 6

Compression:

Stored size: 935 Bytes

Contents

RSpec::Matchers.define :have_menu_items_named do |*expected|
  match do |actual|
    actual.items.names & expected == expected
  end

  description do
    if expected.one?
      "contain a menu item named #{expected.first.to_s}"
    else
      "contain menu items named #{expected.map(&:to_s).join(', ')}"
    end
  end

  failure_message do
    msg = if expected.one?
            "expected menu to contain a menu item named #{expected}"
          else
            "expected menu to contain a menu items named #{expected}"
          end

    msg << "\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(actual.items.names.join("\n"), expected.join("\n"))
  end
end

RSpec::Matchers.alias_matcher :have_a_menu_item_named, :have_menu_items_named

Version data entries

6 entries across 6 versions & 1 rubygems

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