diff options
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/attachment_to_html/adapters/google_docs_viewer_spec.rb | 52 |
1 files changed, 10 insertions, 42 deletions
diff --git a/spec/lib/attachment_to_html/adapters/google_docs_viewer_spec.rb b/spec/lib/attachment_to_html/adapters/google_docs_viewer_spec.rb index 166ca3241..e7aafb40d 100644 --- a/spec/lib/attachment_to_html/adapters/google_docs_viewer_spec.rb +++ b/spec/lib/attachment_to_html/adapters/google_docs_viewer_spec.rb @@ -3,67 +3,35 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe AttachmentToHTML::Adapters::GoogleDocsViewer do let(:attachment) { FactoryGirl.build(:pdf_attachment) } - let(:google_adapter) do + let(:adapter) do AttachmentToHTML::Adapters::GoogleDocsViewer.new(attachment, :attachment_url => 'http://example.com/test.pdf') end - describe :wrapper do + describe :title do - it 'defaults to wrapper_google_embed' do - google_adapter.wrapper.should == 'wrapper_google_embed' - end - - it 'accepts a wrapper option' do - google_adapter = AttachmentToHTML::Adapters::GoogleDocsViewer.new(attachment, :wrapper => 'wrap') - google_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(google_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(google_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 - google_adapter = AttachmentToHTML::Adapters::GoogleDocsViewer.new(attachment, :wrapper => 'wrap') - parsed = Nokogiri::HTML.parse(google_adapter.to_html) do |config| - config.strict - end - parsed.css('body div').first.attributes['id'].value.should == 'wrap' - end + describe :body do - it 'contains the google docs viewer url in the wrapper div' do - options = { :wrapper => 'wrap', :attachment_url => 'http://example.com/test.pdf' } - google_adapter = AttachmentToHTML::Adapters::GoogleDocsViewer.new(attachment, options) - parsed = Nokogiri::HTML.parse(google_adapter.to_html) do |config| - config.strict - end + it 'contains the google docs viewer iframe' do expected = %Q(<iframe src="http://docs.google.com/viewer?url=http://example.com/test.pdf&embedded=true" width="100%" height="100%" style="border: none;"></iframe>) - parsed.css('div#wrap div#view-html-content').inner_html.should include(expected) + adapter.body.should == expected end describe 'uses the confugured alaveteli protocol' do it 'https if force_ssl is on' do AlaveteliConfiguration.stub(:force_ssl).and_return(true) - google_adapter.to_html.should include('https://docs.google.com') + adapter.body.should include('https://docs.google.com') end it 'http if force_ssl is off' do AlaveteliConfiguration.stub(:force_ssl).and_return(false) - google_adapter.to_html.should include('http://docs.google.com') + adapter.body.should include('http://docs.google.com') end end @@ -73,7 +41,7 @@ describe AttachmentToHTML::Adapters::GoogleDocsViewer do describe :success? do it 'is always true' do - google_adapter.success?.should be_true + adapter.success?.should be_true end end |