Sha256: 82e7421c3d624eb0a73f4ead5ae1d73d840a24628592dcca51596fcc47c53dd8

Contents?: true

Size: 1.42 KB

Versions: 6

Compression:

Stored size: 1.42 KB

Contents

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
table_cloth-0.4.0 spec/lib/extensions/actions_spec.rb
table_cloth-0.3.2 spec/lib/extensions/actions_spec.rb
table_cloth-0.3.1.alpha1 spec/lib/extensions/actions_spec.rb
table_cloth-0.3.0.beta3 spec/lib/extensions/actions_spec.rb
table_cloth-0.3.0.beta2 spec/lib/extensions/actions_spec.rb
table_cloth-0.3.0.beta1 spec/lib/extensions/actions_spec.rb