Sha256: de0ea0d250ad0531cce8b57a4434b2947304fd120b941f94a8dbafbb45dec212

Contents?: true

Size: 1.19 KB

Versions: 8

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

describe RakutenWebService::Response do

  describe "Pagenate helpers" do
    let(:resource_class) { double(:resource_class) }

    subject { RakutenWebService::Response.new(resource_class, json) }

    context "When page is less than pageCount" do
      let(:json) do
        {
          'page' => 1, 'pageCount' => 2
        }
      end

      it { is_expected.to have_next_page }
      it { is_expected.to_not be_last_page }
      it { is_expected.to_not have_previous_page }
      it { is_expected.to be_first_page }
    end
    context "When page is equal to pageCount" do
      let(:json) do
        {
          'page' => 2, 'pageCount' => 2
        }
      end

      it { is_expected.to_not have_next_page }
      it { is_expected.to be_last_page }
      it { is_expected.to have_previous_page }
      it { is_expected.to_not be_first_page }
    end
    context "When current page is in pages" do
      let(:json) do
        {
          'page' => 2, 'pageCount' => 3
        }
      end

      it { is_expected.to have_next_page }
      it { is_expected.to_not be_last_page }
      it { is_expected.to have_previous_page }
      it { is_expected.to_not be_last_page }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rakuten_web_service-1.12.0 spec/rakuten_web_service/response_spec.rb
rakuten_web_service-1.11.0 spec/rakuten_web_service/response_spec.rb
rakuten_web_service-1.10.0 spec/rakuten_web_service/response_spec.rb
rakuten_web_service-1.9.2 spec/rakuten_web_service/response_spec.rb
rakuten_web_service-1.9.1 spec/rakuten_web_service/response_spec.rb
rakuten_web_service-1.9.0 spec/rakuten_web_service/response_spec.rb
rakuten_web_service-1.8.0 spec/rakuten_web_service/response_spec.rb
rakuten_web_service-1.7.0 spec/rakuten_web_service/response_spec.rb