Skip to content

Commit

Permalink
changed spec tests to Test Unit Assertions and added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lleïr Borràs Metje committed Dec 24, 2009
1 parent 7ebc2f3 commit 3eaac99
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 39 deletions.
26 changes: 20 additions & 6 deletions Rakefile
@@ -1,9 +1,23 @@
require 'rubygems'
require 'spec/rake/spectask'
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

Spec::Rake::SpecTask.new do |t|
t.warning = true
t.rcov = true
desc 'Default: run unit tests.'
task :default => :test

desc 'Test the wicked_pdf plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end

task :default => :spec
desc 'Generate documentation for the wicked_pdf plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'WickedPdf'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('lib/**/*.rb')
end
12 changes: 6 additions & 6 deletions lib/pdf_helper.rb
Expand Up @@ -35,12 +35,6 @@ def make_and_send_pdf(pdf_name, options = {})
end
end

def parse_options opts
s = "#{parse_header_footer(:header => opts.delete(:header), :footer => opts.delete(:footer), :layout => opts[:layout])} "
s += "#{parse_toc(opts.delete(:toc))} #{parse_outline(opts.delete(:outline))} "
s + "#{parse_margins(opts.delete(:margin))} #{parse_others(opts)} "
end

def make_option name, value, type=:string
"--#{name.gsub('_', '-')} " + case type
when :boolean: ""
Expand All @@ -53,6 +47,12 @@ def make_options opts, names, prefix="", type=:string
names.collect {|o| make_option("#{prefix.blank? ? "" : prefix + "-"}#{o.to_s}", opts[o], type) unless opts[o].blank?}.join
end

def parse_options opts
"#{parse_header_footer(:header => opts.delete(:header), :footer => opts.delete(:footer), :layout => opts[:layout])} " + \
"#{parse_toc(opts.delete(:toc))} #{parse_outline(opts.delete(:outline))} " + \
"#{parse_margins(opts.delete(:margin))} #{parse_others(opts)} "
end

def parse_header_footer opts
r=""
[:header, :footer].collect do |hf|
Expand Down
6 changes: 4 additions & 2 deletions lib/wicked_pdf.rb
Expand Up @@ -9,9 +9,11 @@ class WickedPdf

def initialize(wkhtmltopdf_binary_path = nil)
@exe_path = wkhtmltopdf_binary_path
@exe_path ||= WICKED_PDF[:exe_path] unless WICKED_PDF.blank?
@exe_path ||= WICKED_PDF[:exe_path] unless WICKED_PDF.empty?
@exe_path ||= `which wkhtmltopdf`.chomp
raise "Location of wkhtmltopdf unknown" if @exe_path.blank?
raise "Location of wkhtmltopdf unknown" if @exe_path.empty?
raise "Bad wkhtmltopdf's path" unless File.exists?(@exe_path)
raise "Wkhtmltopdf is not executable" unless File.executable?(@exe_path)
end

def pdf_from_string(string, options=nil)
Expand Down
25 changes: 0 additions & 25 deletions spec/wicked_pdf_spec.rb

This file was deleted.

0 comments on commit 3eaac99

Please sign in to comment.