Sha256: 36c59996893c551c986762d7137c6448209f59b7c7592f60c5c552e7413299ce

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 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 be_next_page }
      it { is_expected.to_not be_last_page }
      it { is_expected.to_not be_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 be_next_page }
      it { is_expected.to be_last_page }
      it { is_expected.to be_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 be_next_page }
      it { is_expected.to_not be_last_page }
      it { is_expected.to be_previous_page }
      it { is_expected.to_not be_last_page }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rakuten_web_service-1.13.2 spec/rakuten_web_service/response_spec.rb
rakuten_web_service-1.13.1 spec/rakuten_web_service/response_spec.rb
rakuten_web_service-1.13.0 spec/rakuten_web_service/response_spec.rb