require 'test_helper'
module PaginatedTable
describe TableRenderer do
let(:view) { stub("view") }
let(:description) { stub("description") }
let(:data) { stub("data") }
let(:page) { stub("page", :sort_column => 'title', :sort_direction => 'asc') }
let(:data_page) { stub("data_page", :data => data, :page => page) }
let(:link_renderer) { stub("link_renderer") }
let(:table) { TableRenderer.new(view, description, data_page, link_renderer) }
describe "#initialize" do
it "creates a new instance with the view, description, and data_page" do
table
end
end
describe "#render" do
it "makes a div.paginated_table with the table and a pagination header and footer" do
table.stubs(:render_pagination_area).returns("")
table.stubs(:render_table).returns("
")
view.expects(:content_tag).with('div', "", :class => 'paginated_table')
table.render
end
end
describe "#render_pagination_area" do
it "makes a div.header with the pagination info and links" do
table.stubs(:render_pagination_info).returns("")
table.stubs(:render_pagination_links).returns("")
view.expects(:content_tag).with('div', "", :class => 'header')
table.render_pagination_area
end
end
describe "#render_pagination_info" do
it "makes a div.info with the page_entries_info from will_paginate" do
view.stubs(:page_entries_info).with(data).returns("")
view.expects(:content_tag).with('div', "", :class => 'info')
table.render_pagination_info
end
end
describe "#render_pagination_links" do
it "makes a div.links with the will_paginate links from will_paginate" do
view.stubs(:will_paginate).
with(data, :renderer => link_renderer).
returns("")
view.expects(:content_tag).with('div', "", :class => 'links')
table.render_pagination_links
end
end
describe "#render_table" do
it "makes a table.paginated with the table header and body" do
table.stubs(:render_table_header).returns("")
table.stubs(:render_table_body).returns("