diff options
author | Gareth Rees <gareth@mysociety.org> | 2014-04-02 12:25:27 +0100 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2014-04-07 17:14:07 +0100 |
commit | 7a30de942b03156bc8220471c23aca52143a14a1 (patch) | |
tree | b5c2b1c2fe6712529733808264fbd54f5b0ffe00 /spec/lib/attachment_to_html | |
parent | 50ed310bed98ea23f813a5abd4210e34711dfb4c (diff) |
Simpler AttachmentToHTML::Adapters::CouldNotConvert interface
Diffstat (limited to 'spec/lib/attachment_to_html')
-rw-r--r-- | spec/lib/attachment_to_html/adapters/could_not_convert_spec.rb | 49 |
1 files changed, 9 insertions, 40 deletions
diff --git a/spec/lib/attachment_to_html/adapters/could_not_convert_spec.rb b/spec/lib/attachment_to_html/adapters/could_not_convert_spec.rb index aee68e986..afdc5c552 100644 --- a/spec/lib/attachment_to_html/adapters/could_not_convert_spec.rb +++ b/spec/lib/attachment_to_html/adapters/could_not_convert_spec.rb @@ -3,55 +3,24 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe AttachmentToHTML::Adapters::CouldNotConvert do let(:attachment) { FactoryGirl.build(:pdf_attachment) } - let(:adapter) { AttachmentToHTML::Adapters::CouldNotConvert.new(attachment) } - - describe :wrapper do + let(:adapter) do + AttachmentToHTML::Adapters::CouldNotConvert.new(attachment) + end - it 'defaults to wrapper' do - adapter.wrapper.should == 'wrapper' - end + describe :title do - it 'accepts a wrapper option' do - adapter = AttachmentToHTML::Adapters::CouldNotConvert.new(attachment, :wrapper => 'wrap') - adapter.wrapper.should == 'wrap' + it 'uses the attachment filename for the title' do + adapter.title.should == attachment.display_filename end end - describe :to_html do - - it 'should be a valid html document' do - parsed = Nokogiri::HTML.parse(adapter.to_html) do |config| - config.strict - end - parsed.errors.any?.should be_false - end - - it 'contains the attachment filename in the title tag' do - parsed = Nokogiri::HTML.parse(adapter.to_html) do |config| - config.strict - end - parsed.css('title').inner_html.should == attachment.display_filename - end - - it 'contains the wrapper div in the body tag' do - adapter = AttachmentToHTML::Adapters::CouldNotConvert.new(attachment, :wrapper => 'wrap') - parsed = Nokogiri::HTML.parse(adapter.to_html) do |config| - config.strict - end - parsed.css('body div').first.attributes['id'].value.should == 'wrap' - end - - it 'should contain text about the conversion failure' do - adapter = AttachmentToHTML::Adapters::CouldNotConvert.new(attachment, :wrapper => 'wrap') - parsed = Nokogiri::HTML.parse(adapter.to_html) do |config| - config.strict - end + describe :body do + it 'contains a message asking the user to download the file directly' do expected = "<p>Sorry, we were unable to convert this file to HTML. " \ "Please use the download link at the top right.</p>" - - parsed.css('div#wrap div#view-html-content').inner_html.should == expected + adapter.body.should == expected end end |