spec/helpers/application_helper_spec.rb in curate-0.2.0 vs spec/helpers/application_helper_spec.rb in curate-0.3.1
- old
+ new
@@ -5,36 +5,45 @@
expect(helper.sufia).to eq(helper)
end
it 'has #default_page_title' do
expect(helper.default_page_title).to(
- eq("#{controller_name.titleize} // CurateND")
+ eq("#{controller_name.titleize} // #{I18n.t('sufia.product_name')}")
)
end
it 'has #curation_concern_page_title' do
expect(helper.curation_concern_page_title(MockCurationConcern.new)).to(
- eq("New Mock Curation Concern // CurateND")
+ eq("New Mock Curation Concern // #{I18n.t('sufia.product_name')}")
)
end
describe '#curation_concern_attribute_to_html' do
it 'handles an array by rendering one <dd> per element' do
collection = ["<h2>", "Johnny Tables"]
object = double('curation_concern', things: collection)
- expect(helper.curation_concern_attribute_to_html(object, :things, "Weird")).to(
- eq("<dt>Weird</dt>\n<dd class=\"attribute things\"><h2></dd>\n<dd class=\"attribute things\">Johnny Tables</dd>\n")
- )
+ rendered = helper.curation_concern_attribute_to_html(object, :things, "Weird")
+ rendered.should have_tag('tr') do
+ with_tag("th", text: 'Weird')
+ with_tag('td ul.tabular') do
+ with_tag('li.attribute.things', text: '<h2>')
+ with_tag('li.attribute.things', text: 'Johnny Tables')
+ end
+ end
end
it 'handles a string by rendering one <dd>' do
collection = "Tim"
object = double('curation_concern', things: collection)
- expect(helper.curation_concern_attribute_to_html(object, :things, "Weird")).to(
- eq("<dt>Weird</dt>\n<dd class=\"attribute things\">Tim</dd>\n")
- )
+ rendered = helper.curation_concern_attribute_to_html(object, :things, "Weird")
+ rendered.should have_tag('tr') do
+ with_tag("th", text: 'Weird')
+ with_tag('td ul.tabular') do
+ with_tag('li.attribute.things', text: 'Tim')
+ end
+ end
end
it 'returns a '' for a nil value' do
collection = nil
object = double('curation_concern', things: collection)
@@ -47,9 +56,21 @@
object = double('curation_concern', things: collection)
expect(helper.curation_concern_attribute_to_html(object, :things, "Weird")).to(
eq("")
)
+ end
+ it 'returns a string for an empty array if allow_empty is passed' do
+ collection = []
+ object = double('curation_concern', things: collection)
+
+ rendered = helper.curation_concern_attribute_to_html(object, :things, "Weird", include_empty: true)
+ rendered.should have_tag('tr') do
+ with_tag("th", text: 'Weird')
+ with_tag('td ul.tabular') do
+ without_tag('li.attribute.things')
+ end
+ end
end
end
it 'has #classify_for_display' do
expect(helper.classify_for_display(MockCurationConcern.new)).to eq('mock curation concern')