Sha256: 2d6c6948b9ff99c1b219dd59195c664d288e857a3f74837a0bee10df44a31518

Contents?: true

Size: 707 Bytes

Versions: 2

Compression:

Stored size: 707 Bytes

Contents

Spec::Matchers.define :include_on_any_page do |expected|
  match do |collection|
    on_any_page?(collection, expected)
  end

  def on_any_page?(collection, expected)
    return true if collection.any? { |item| item.id == expected.id }
    return false if collection.last_page?

    on_any_page?(collection.next_page, expected)
  end

  failure_message_for_should do |collection|
    "expected that the paged collection would include an item with id #{expected.id}"
  end

  failure_message_for_should_not do |collection|
    "expected that the paged collection would not include an item with id #{expected.id}"
  end

  description do
    "include the given subsription in the paged collection"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
braintree-1.2.1 spec/support/matchers/include_on_any_page.rb
braintree-1.2.0 spec/support/matchers/include_on_any_page.rb