Sha256: 0c6e2263a320a8cf9088a534956da8cbd47ef60d4276370bb3936a3d2c438613

Contents?: true

Size: 954 Bytes

Versions: 2

Compression:

Stored size: 954 Bytes

Contents

shared_examples_for "a paginated class" do
  it { subject.class.included_modules.should include(BookingSync::Pagination) }

  it ".find_all_across_pages" do
    subject.class.should_receive(:find).with(:all, {
      :params => { :page => 1 }}).and_return(["things"])
    subject.class.should_receive(:find).with(:all,{
      :params => { :page => 2 }}).and_return([])
    subject.class.find_all_across_pages.should == ["things"]
  end
  
  it ".find_all_across_pages with zero results" do
    subject.class.should_receive(:find).with(:all,{
      :params => { :page => 1 }}).and_return(nil)
    subject.class.find_all_across_pages.should == []
  end
  
  it ".find_all_across_pages_since" do
    time = Time.parse("Fri Jan 07 12:34:56 +0200 2011")
    subject.class.should_receive(:find_all_across_pages).with({
      :params => { :from => "20110107"}}).and_return("result")
    subject.class.find_all_across_pages_from(time).should == "result"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bookingsync-0.1.1 spec/bookingsync/pagination_behavior.rb
bookingsync-0.1.0 spec/bookingsync/pagination_behavior.rb