Sha256: 00b51af4c5562bb8d6781bf3359209d242b9f4ead4b91877ced3ae14646051e9
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
require 'spec_helper' describe TableCloth::Column do subject { Class.new(TableCloth::Column) } let(:view_context) { ActionView::Base.new } let(:dummy_model) do DummyModel.new.tap do |d| d.id = 1 d.email = 'robert@example.com' d.name = 'robert' end end context 'values' do let(:name_column) do TableCloth::Column.new(:name) end let(:email_column) do proc = lambda {|object, options, view| object.email } TableCloth::Column.new(:my_email, proc: proc) end it 'returns the name correctly' do name_column.value(dummy_model, view_context).should == 'robert' end it 'returns the email from a proc correctly' do email_column.value(dummy_model, view_context).should == 'robert@example.com' end context '.available?' do let(:dummy_table) do Class.new(TableCloth::Table) do column :name, if: :admin? def admin? view.admin? end end end it 'returns true on successful constraint' do table = Class.new(DummyTable).new([dummy_model], view_context) column = TableCloth::Column.new(:name, if: :admin?) column.available?(table).should be_true end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
table_cloth-0.1.1 | spec/lib/column_spec.rb |
table_cloth-0.1.0 | spec/lib/column_spec.rb |