Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Update specs to use asset corresponding to prawn version

  • Loading branch information...
commit c53da964cf556ef459474e79f531c0c8d60fce26 1 parent e4e25a6
rylwin authored
2  spec/integrations/super_model_spec.rb
@@ -8,7 +8,7 @@
8 8
     end
9 9
     
10 10
     it do
11  
-      asset_binary = File.open(TEST_ASSETS + "/default_render.pdf").read.bytes.to_a
  11
+      asset_binary = File.open(asset_path('default_render')).read.bytes.to_a
12 12
       @model.to_pdf.bytes.to_a.should == asset_binary
13 13
     end
14 14
   end
8  spec/integrations/test_controller_spec.rb
@@ -7,7 +7,7 @@
7 7
       get "/default_render.pdf"
8 8
       response.should be_success
9 9
       
10  
-      asset_binary = File.open(TEST_ASSETS + "/default_render.pdf").read.bytes.to_a
  10
+      asset_binary = File.open(asset_path("default_render")).read.bytes.to_a
11 11
       body_binary = response.body.bytes.to_a
12 12
       body_binary.should == asset_binary
13 13
     end
@@ -19,7 +19,7 @@
19 19
     
20 20
     it "should render items in a block passed to a helper" do
21 21
       get "/yield_block_in_helper_test.pdf"
22  
-      asset_binary = File.open(TEST_ASSETS + "/yield_block_in_helper_test.pdf").read.bytes.to_a
  22
+      asset_binary = File.open(asset_path("yield_block_in_helper_test")).read.bytes.to_a
23 23
       body_binary = response.body.bytes.to_a
24 24
       body_binary.should == asset_binary
25 25
     end
@@ -31,10 +31,10 @@
31 31
       get "/dsl_render.pdf"
32 32
       response.should be_success
33 33
       
34  
-      asset_binary = File.open(TEST_ASSETS + "/dsl_render.pdf").read.bytes.to_a
  34
+      asset_binary = File.open(asset_path("dsl_render")).read.bytes.to_a
35 35
       body_binary = response.body.bytes.to_a
36 36
       body_binary.should == asset_binary
37 37
     end
38 38
   end
39 39
 
40  
-end
  40
+end
9  spec/spec_helper.rb
... ...
@@ -1,7 +1,6 @@
1 1
 require 'rubygems'
2 2
 require 'spork'
3 3
 
4  
-raise Gem.loaded_specs["prawn"].version.to_s.inspect
5 4
 Spork.prefork do
6 5
   # Configure Rails Environment
7 6
   ENV["RAILS_ENV"] = "test"
@@ -28,3 +27,11 @@
28 27
   # This code will be run each time you run your specs.
29 28
 
30 29
 end
  30
+
  31
+# Helper to provide asset path given the "base name" of the file.
  32
+# For example, if +file+ is "default_render", asset_path returns
  33
+# "/path/to/prawnto/spec/assets/default_render-#{prawn version}.pdf"
  34
+def asset_path(file)
  35
+  prawn_version = Gem.loaded_specs["prawn"].version.to_s.inspect
  36
+  TEST_ASSETS + "/#{file}-#{prawn_version.gsub('"','')}.pdf"
  37
+end

0 notes on commit c53da96

Please sign in to comment.
Something went wrong with that request. Please try again.