# encoding: UTF-8 require 'spec_helper' describe Table do describe 'for_supplier' do let(:supplier){ create(:supplier) } let(:options){ Hash.new } subject{ Table.for_supplier(supplier, options) } it "should return an empty array by default" do subject.should be_empty end describe 'with multiple tables' do before do @table1 = create :table, supplier: supplier, number: 2 @table2 = create :table, supplier: supplier, number: 4 @table3 = create :table, supplier: supplier, number: 6 @table4 = create :table, number: 4 end it "returns all by default" do subject.should == [@table1, @table2, @table3] end it "should paginate the result" do options[:per_page] = 2 subject.size.should == 2 subject.total_count.should == 3 end end end end