Permalink
Browse files

Update specs to use asset corresponding to prawn version

  • Loading branch information...
1 parent e4e25a6 commit c53da964cf556ef459474e79f531c0c8d60fce26 @rylwin rylwin committed Feb 1, 2012
Showing with 13 additions and 6 deletions.
  1. +1 −1 spec/integrations/super_model_spec.rb
  2. +4 −4 spec/integrations/test_controller_spec.rb
  3. +8 −1 spec/spec_helper.rb
View
2 spec/integrations/super_model_spec.rb
@@ -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
View
8 spec/integrations/test_controller_spec.rb
@@ -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
@@ -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
@@ -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
View
9 spec/spec_helper.rb
@@ -1,7 +1,6 @@
require 'rubygems'
require 'spork'
-raise Gem.loaded_specs["prawn"].version.to_s.inspect
Spork.prefork do
# Configure Rails Environment
ENV["RAILS_ENV"] = "test"
@@ -28,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 c53da96

Please sign in to comment.