Sha256: 295ef20ff1610241b92abcd11db41699e73f419aa15ee261da42e5db3e9531b1

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

require File.dirname(__FILE__) + '/../../test_helper.rb'

class TestNytimes::TestMovies::TestResultSet < Test::Unit::TestCase
	include Nytimes::Movies

	def setup
		@reply = MOVIE_RESULT_HASH
		@params = {'offset' => 40}
		@result_set = ResultSet.new(@params, @reply, Review)
	end
	
	context "first_index" do
		should "equal the offset + 1" do
			assert_equal 41, @result_set.first_index
		end
	end
	
	context "last_index" do
		should "equal the first_index + batch_size - 1" do
			assert_equal 60, @result_set.last_index
		end
	end

	context "num_pages" do
		should "equal the ceiling of num_results / batch_size" do
			@result_set.instance_variable_set '@num_results', 123
			
			assert_equal 7, @result_set.num_pages
		end
		
		should "equal 1 if the number of results < batch_size" do
			@result_set.instance_variable_set '@num_results', 1
			assert_equal 1, @result_set.num_pages
		end
		
		should "not erroneously round up if the num_results % batch_size = 0" do
			@result_set.instance_variable_set '@num_results', 120
			assert_equal 6, @result_set.num_pages
		end
	end
	
	context "page_number" do
		should "equal the offset / batch_size + 1" do
			assert_equal 3, @result_set.page_number
		end
	end
	
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
harrisj-nytimes-movies-0.1.0 test/nytimes/movies/test_result_set.rb
harrisj-nytimes-movies-0.1.1 test/nytimes/movies/test_result_set.rb
nytimes-movies-0.1.1 test/nytimes/movies/test_result_set.rb