Sha256: 845657ef96d6aeb9e568149608e4e4056c841af4b153e20cfbe80221e8d28859

Contents?: true

Size: 526 Bytes

Versions: 2

Compression:

Stored size: 526 Bytes

Contents

RSpec::Matchers.define :have_pagination_links do |page|
  match do |response_headers|
    if page.nil?
      true
    else
      links = response_headers['Link'] || '' # https://github.com/lostisland/faraday/pull/306
      rels = links.split(',').map{|link| link[/<.+?>; rel="(.*)"$/, 1]}
      rels.sort == ['first', 'prev']
    end
  end

  description do
    %Q(include 'Link' (for pagination))
  end

  failure_message_for_should do |response_headers|
    %Q(should #{description}, but are #{response_headers})
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec-api-0.1.1 lib/rspec-api/matchers/page.rb
rspec-api-0.1.0 lib/rspec-api/matchers/page.rb