Skip to content

Commit

Permalink
test yielding block of default_main_content
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Cichra committed Aug 27, 2014
1 parent d569bf0 commit e96f75e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion spec/unit/views/pages/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,29 @@
describe "the resource" do
let(:helpers) { double resource: resource }
let(:arbre_context) { Arbre::Context.new({}, helpers) }
subject(:page) { ActiveAdmin::Views::Pages::Show.new(arbre_context) }

context 'when the resource does not respond to #decorator' do
let(:resource) { 'Test Resource' }

it "normally returns the resource" do
page = ActiveAdmin::Views::Pages::Show.new(arbre_context)
expect(page.resource).to eq 'Test Resource'
end
end

context 'when you pass a block to main content' do
let(:block) { lambda { } }
let(:resource_class) { double(columns: [double('column', name: 'field')]) }
let(:resource) { double('resource', class: resource_class) }

before { allow(page).to receive(:active_admin_config).and_return(double(comments?: false))}

it 'appends it to the output' do
expect(page).to receive(:attributes_table).with(:field).and_yield
page.default_main_content(&block)
end
end

end

end

0 comments on commit e96f75e

Please sign in to comment.