Sha256: d2aed9174279a4fc7797eb8e15facbd1041e073a93c3452f455842e25856eafb

Contents?: true

Size: 667 Bytes

Versions: 6

Compression:

Stored size: 667 Bytes

Contents

RSpec::Matchers.define :have_exactly do |expected|
  match do |actual|
    if @sections
      actual.sections.size == expected
    else
      actual.items.size == expected
    end
  end

  description do
    "contain exactly #{expected} menu #{@sections ? 'sections' : 'items'}"
  end

  failure_message do
    msg = "expected that the menu would contain #{expected} #{@sections ? 'sections' : 'items'}; actually contains "
    msg << (@sections ? actual.sections.size : actual.items.size).to_s
    msg
  end

  chain(:item) { @sections = false }
  chain(:items) { @sections = false }
  chain(:section) { @sections = true }
  chain(:sections) { @sections = true }
end

Version data entries

6 entries across 6 versions & 1 rubygems

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