Sha256: 97ffc87be061d646f501f2886917d2cd21d00f23f5da416b95097fe4b57c27dd

Contents?: true

Size: 1.32 KB

Versions: 11

Compression:

Stored size: 1.32 KB

Contents

require 'test_helper'

module Minitest
  # Add assertions to Minitest
  module Assertions
    def assert_valid_object_pages(object_name, limit, page_count)
      district = Clever::District.all.first
      object_count_from_list = district.send("#{object_name}s", limit: 100_000).size

      object_count_from_paging = 0
      pages = 0
      district.send("#{object_name}_pages", limit: limit).each do |object_page|
        pages += 1
        objects = object_page.all
        object_count_from_paging += objects.size
      end

      object_count_from_paging.must_equal object_count_from_list
      pages.must_equal page_count
    end
  end
end

describe Clever::District, :vcr do
  before do
    Clever.configure do |config|
      config.token = 'DEMO_TOKEN'
    end
  end

  # TODO: this is outdated and should be removed!
  describe 'pages methods' do
    it "pages a district's schools" do
      assert_valid_object_pages 'school', 2, 2
    end

    it "pages a district's teachers" do
      assert_valid_object_pages 'teacher', 10, 9
    end

    it "pages a district's sections" do
      assert_valid_object_pages 'section', 10, 38
    end

    it "pages a district's students" do
      assert_valid_object_pages 'student', 50, 21
    end

    it "pages a district's events" do
      assert_valid_object_pages 'event', 1, 8
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
clever-ruby-0.14.0 test/integration/district_test.rb
clever-ruby-0.13.2 test/integration/district_test.rb
clever-ruby-0.13.1 test/integration/district_test.rb
clever-ruby-0.13.0 test/integration/district_test.rb
clever-ruby-0.11.1 test/integration/district_test.rb
clever-ruby-0.11.0 test/integration/district_test.rb
clever-ruby-0.10.2 test/integration/district_test.rb
clever-ruby-0.10.1 test/integration/district_test.rb
clever-ruby-0.10.0 test/integration/district_test.rb
clever-ruby-0.9.0 test/integration/district_test.rb
clever-ruby-0.8.0 test/integration/district_test.rb