require 'spec_helper' describe 'Action View integration' do let(:context) { RailsViewContext.new } describe '#simple_table_for' do let(:collection) { [ first_post, second_post ] } let(:first_post) { Post.new('1') } let(:second_post) { Post.new('2') } it 'produces HTML' do result = context.table_for(collection) do |table, record| table.column :title table.actions do table.action :show, '/foo', 'Show' end end expect(result).to eq <<-HTML.strip
TitleActions
Post 1Show
Post 2Show
HTML end end describe '#filters_for' do let(:params) { { query: { bar: 'one' } } } let(:query) { TestQuery.new(params) } it 'produces HTML' do result = "" context.filters_for(query) do |group| result << "#{group.name}: " group.each_scope do |scope| result << scope.link end end expect(result).to eq <<-HTML.strip Bar: EmptyOneTwo HTML end end describe '#sortings_for' do let(:params) { { sorting: 'by_title', sort_order: 'desc' } } let(:query) { TestQuery.new(params) } it 'produces HTML' do result = "" context.sortings_for(query) do |scope| result << scope.link end expect(result).to eq <<-HTML.strip By titleBy date HTML end end describe '#search_form_for' do let(:params) { { query: { foo: 'test' } } } let(:query) { TestQuery.new(params) } it 'produces HTML' do result = context.search_form_for(query) do |f| f.text_field :foo end expect(result).to eq <<-HTML.strip
HTML end end describe '#simple_search_form_for' do let(:params) { { query: { foo: 'test' } } } let(:query) { TestQuery.new(params) } it 'produces HTML' do result = context.simple_search_form_for(query) do |f| f.input :foo end expect(result).to eq <<-HTML.strip
HTML end end end