Skip to content

Commit

Permalink
Merge pull request prior#5 from rylwin/master
Browse files Browse the repository at this point in the history
Merging @rylwin's changes to allow a wider range of prawn versions.
  • Loading branch information
forrest committed Feb 1, 2012
2 parents 5b0f29e + c53da96 commit c969980
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ rdoc/
Gemfile.lock
spec/dummy/tmp
spec/dummy/log
gemfiles
7 changes: 7 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
appraise "prawn0.12.0" do
gem "prawn", '0.12.0'
end

appraise "prawn0.6.3" do
gem "prawn", '0.6.3'
end
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ gemspec
gem "spork", ">= 0.9.0"
gem "rspec-rails"
gem "mocha"
gem "appraisal"
14 changes: 14 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ Sometimes you need to be able to render a PDF from anywhere (Background process

While layouts and partials aren't yet supported, helper methods can be called from within the PDF views. To help keep PDF's DRY, I would recommend creating a <code>PdfHelper</code> class for complex functionality. Don't forget to add this helper to your emailer if you generate PDF's as attachments.

== Testing

prawnto uses appraisal to run tests for different versions of prawn. In order to
run the specs you first need to install the dependencies for each appraisal:

rake appraisal:install

Then you can run the tests for a specifc version of prawn (only 0.12.0 and
0.6.3, but you can add your own version) or all versions:

rake appraisal:prawn0.12.0 spec
rake appraisal:prawn0.6.3 spec
rake appraisal spec # all versions

= Contributing & Reporting Issues

Obviously, all code contributions are greatly appreciated. We also need help with testing and the wiki.
Expand Down
18 changes: 11 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
require 'rubygems'
require 'bundler/setup'

require 'rake'
require 'rake/testtask'
require 'rdoc/task'
require 'rubygems/package_task'

desc 'Default: run unit tests.'
task :default => :test
require 'appraisal'

desc 'Generate documentation for the prawnto plugin.'
RDoc::Task.new do |rdoc|
Expand All @@ -15,9 +17,11 @@ RDoc::Task.new do |rdoc|
rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb")
end

desc 'Test the prawnto gem'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/*_test.rb'
# t.verbose = true
require 'rspec/core/rake_task'

desc 'Default: run specs.'
task :default => :spec

desc "Run specs"
RSpec::Core::RakeTask.new do |t|
end
2 changes: 1 addition & 1 deletion prawnto.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = ">= 1.3.6"
s.platform = Gem::Platform::RUBY
s.add_dependency('rails', '>= 3.1')
s.add_dependency('prawn', '>= 0.12.0')
s.add_dependency('prawn', '>= 0.6.0')

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
Expand Down
File renamed without changes.
Binary file added spec/assets/default_render-0.6.3.pdf
Binary file not shown.
File renamed without changes.
Binary file added spec/assets/dsl_render-0.6.3.pdf
Binary file not shown.
File renamed without changes.
Binary file added spec/assets/yield_block_in_helper_test-0.6.3.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion spec/integrations/super_model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
end

it do
asset_binary = File.open(TEST_ASSETS + "/default_render.pdf").read.bytes.to_a
asset_binary = File.open(asset_path('default_render')).read.bytes.to_a
@model.to_pdf.bytes.to_a.should == asset_binary
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/integrations/test_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
get "/default_render.pdf"
response.should be_success

asset_binary = File.open(TEST_ASSETS + "/default_render.pdf").read.bytes.to_a
asset_binary = File.open(asset_path("default_render")).read.bytes.to_a
body_binary = response.body.bytes.to_a
body_binary.should == asset_binary
end
Expand All @@ -19,7 +19,7 @@

it "should render items in a block passed to a helper" do
get "/yield_block_in_helper_test.pdf"
asset_binary = File.open(TEST_ASSETS + "/yield_block_in_helper_test.pdf").read.bytes.to_a
asset_binary = File.open(asset_path("yield_block_in_helper_test")).read.bytes.to_a
body_binary = response.body.bytes.to_a
body_binary.should == asset_binary
end
Expand All @@ -31,10 +31,10 @@
get "/dsl_render.pdf"
response.should be_success

asset_binary = File.open(TEST_ASSETS + "/dsl_render.pdf").read.bytes.to_a
asset_binary = File.open(asset_path("dsl_render")).read.bytes.to_a
body_binary = response.body.bytes.to_a
body_binary.should == asset_binary
end
end

end
end
8 changes: 8 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@
# This code will be run each time you run your specs.

end

# Helper to provide asset path given the "base name" of the file.
# For example, if +file+ is "default_render", asset_path returns
# "/path/to/prawnto/spec/assets/default_render-#{prawn version}.pdf"
def asset_path(file)
prawn_version = Gem.loaded_specs["prawn"].version.to_s.inspect
TEST_ASSETS + "/#{file}-#{prawn_version.gsub('"','')}.pdf"
end

0 comments on commit c969980

Please sign in to comment.