Permalink
Browse files

Update test suite

  • Loading branch information...
1 parent e6effc4 commit 565e4b91ca47f8b97fc70df8895a6839f53bef69 @unixmonkey unixmonkey committed Aug 28, 2012
Showing with 28 additions and 24 deletions.
  1. +7 −5 test/pdf_helper_test.rb
  2. +17 −15 test/wicked_pdf_helper_test.rb
  3. +4 −4 test/wicked_pdf_test.rb
View
@@ -17,10 +17,12 @@ def teardown
@ac=nil
end
- test "should prerender header and footer :template options" do
- options = @ac.send( :prerender_header_and_footer,
- :header => {:html => { :template => 'hf.html.erb'}});
- assert !options[:header][:html].has_key?(:template)
- assert_match /^file:\/\/.*wicked_header_pdf.*\.html/, options[:header][:html][:url]
+ if Rails::VERSION::MAJOR == 2
+ test "should prerender header and footer :template options" do
+ options = @ac.send( :prerender_header_and_footer,
+ :header => {:html => { :template => 'hf.html.erb'}});
+ assert !options[:header][:html].has_key?(:template)
+ assert_match /^file:\/\/.*wicked_header_pdf.*\.html/, options[:header][:html][:url]
+ end
end
end
@@ -2,23 +2,25 @@
require 'action_view/test_case'
class WickedPdfHelperTest < ActionView::TestCase
- test 'wicked_pdf_stylesheet_link_tag should inline the stylesheets passed in' do
- assert_equal "<style type='text/css'>/* Wicked styles */\n</style>",
- wicked_pdf_stylesheet_link_tag('../../vendor/plugins/wicked_pdf/test/fixtures/wicked')
- end
+ if Rails::VERSION::MAJOR == 2
+ test 'wicked_pdf_stylesheet_link_tag should inline the stylesheets passed in' do
+ assert_equal "<style type='text/css'>/* Wicked styles */\n</style>",
+ wicked_pdf_stylesheet_link_tag('../../vendor/plugins/wicked_pdf/test/fixtures/wicked')
+ end
- test 'wicked_pdf_image_tag should return the same as image_tag when passed a full path' do
- assert_equal image_tag("file://#{Rails.root.join('public','images','pdf')}"),
- wicked_pdf_image_tag('pdf')
- end
+ test 'wicked_pdf_image_tag should return the same as image_tag when passed a full path' do
+ assert_equal image_tag("file://#{Rails.root.join('public','images','pdf')}"),
+ wicked_pdf_image_tag('pdf')
+ end
- test 'wicked_pdf_javascript_src_tag should return the same as javascript_src_tag when passed a full path' do
- assert_equal javascript_src_tag("file://#{Rails.root.join('public','javascripts','pdf')}", {}),
- wicked_pdf_javascript_src_tag('pdf')
- end
+ test 'wicked_pdf_javascript_src_tag should return the same as javascript_src_tag when passed a full path' do
+ assert_equal javascript_src_tag("file://#{Rails.root.join('public','javascripts','pdf')}", {}),
+ wicked_pdf_javascript_src_tag('pdf')
+ end
- test 'wicked_pdf_include_tag should return many wicked_pdf_javascript_src_tags' do
- assert_equal [wicked_pdf_javascript_src_tag('foo'), wicked_pdf_javascript_src_tag('bar')].join("\n"),
- wicked_pdf_javascript_include_tag('foo', 'bar')
+ test 'wicked_pdf_include_tag should return many wicked_pdf_javascript_src_tags' do
+ assert_equal [wicked_pdf_javascript_src_tag('foo'), wicked_pdf_javascript_src_tag('bar')].join("\n"),
+ wicked_pdf_javascript_include_tag('foo', 'bar')
+ end
end
end
View
@@ -84,20 +84,20 @@ class WickedPdfTest < ActiveSupport::TestCase
wp = WickedPdf.new
[:font_name, :header_text].each do |o|
- assert_equal "--toc-#{o.to_s.gsub('_', '-')} \"toc\"",
+ assert_equal "--toc --toc-#{o.to_s.gsub('_', '-')} \"toc\"",
wp.get_parsed_options(:toc => {o => "toc"}).strip
end
[ :depth, :header_fs, :l1_font_size, :l2_font_size, :l3_font_size, :l4_font_size,
:l5_font_size, :l6_font_size, :l7_font_size, :l1_indentation, :l2_indentation,
:l3_indentation, :l4_indentation, :l5_indentation, :l6_indentation, :l7_indentation
].each do |o|
- assert_equal "--toc-#{o.to_s.gsub('_', '-')} 5",
+ assert_equal "--toc --toc-#{o.to_s.gsub('_', '-')} 5",
wp.get_parsed_options(:toc => {o => 5}).strip
end
[:no_dots, :disable_links, :disable_back_links].each do |o|
- assert_equal "--toc-#{o.to_s.gsub('_', '-')}",
+ assert_equal "--toc --toc-#{o.to_s.gsub('_', '-')}",
wp.get_parsed_options(:toc => {o => true}).strip
end
end
@@ -129,7 +129,7 @@ class WickedPdfTest < ActiveSupport::TestCase
[:cookie, :post].each do |o|
assert_equal "--#{o.to_s.gsub('_', '-')} name value", wp.get_parsed_options(o => "name value").strip
- nv_formatter = ->(number){ "--#{o.to_s.gsub('_', '-')} par#{number} val#{number}" }
+ nv_formatter = Proc.new{|number| "--#{o.to_s.gsub('_', '-')} par#{number} val#{number}" }
assert_equal "#{nv_formatter.call(1)} #{nv_formatter.call(2)}", wp.get_parsed_options(o => ['par1 val1', 'par2 val2']).strip
end

0 comments on commit 565e4b9

Please sign in to comment.