Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

42 lines (34 sloc) 1.457 kB
require "spec_helper"
describe TableCloth::Extensions::Actions do
let(:dummy_table) { FactoryGirl.build(:dummy_table) }
context "inclusion" do
it "gives the table class an actions method" do
expect { dummy_table.send(:include, described_class) }.to change { dummy_table.respond_to? :actions }.to true
end
context ".actions" do
before(:each) { dummy_table.send(:include, described_class) }
it "yields an ActionCollection block" do
block_type = nil
dummy_table.actions { block_type = self }
expect(block_type).to be_kind_of TableCloth::Extensions::Actions::ActionCollection
end
it "creates an actions column on the table" do
dummy_table.actions { }
expect(dummy_table.columns).to have_key :actions
end
it "accepts options" do
dummy_table.actions(if: :admin?) { }
expect(dummy_table.columns[:actions][:options]).to have_key :if
end
it "sets a collection key for the column pointing to the collection object" do
dummy_table.actions { }
expect(dummy_table.columns[:actions][:options][:collection]).to be_kind_of TableCloth::Extensions::Actions::ActionCollection
end
it "sets the column class to an action column" do
dummy_table.actions { }
column = dummy_table.columns[:actions]
expect(column[:class]).to eq(TableCloth::Extensions::Actions::Column)
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.