forked from GetJobber/prawnto
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
94 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
text "inside partial" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
text "before partial" | ||
partial! "test/simple_partial" | ||
text "after partial" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
Rails.application.routes.draw do | ||
get "/default_render" => "test#default_render" | ||
get "/partial_render" => "test#partial_render" | ||
get "/dsl_render" => "test#dsl_render" | ||
get "/instance_var_test" => "test#instance_var_test" | ||
get "/yield_block_in_helper_test" => "test#yield_block_in_helper_test" | ||
|
||
root :to => "test#default_render" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,51 @@ | ||
require File.expand_path("../spec_helper.rb", File.dirname(__FILE__)) | ||
|
||
describe TestController do | ||
|
||
describe "simple" do | ||
it "returns correct PDF" do | ||
get "/default_render.pdf" | ||
response.should be_success | ||
|
||
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 | ||
|
||
|
||
it "shares values/changes of instance vars between view and helpers" do | ||
expect { get "/instance_var_test.pdf" }.should_not raise_error | ||
end | ||
|
||
it "should render items in a block passed to a helper" do | ||
get "/yield_block_in_helper_test.pdf" | ||
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 | ||
end | ||
|
||
|
||
describe "dsl" do | ||
it "returns correct PDF" do | ||
get "/dsl_render.pdf" | ||
response.should be_success | ||
|
||
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 | ||
|
||
describe "partials" do | ||
it "renders partials" do | ||
get "/partial_render.pdf" | ||
response.should be_success | ||
|
||
asset_binary = File.open(asset_path("partial_render")).read.bytes.to_a | ||
body_binary = response.body.bytes.to_a | ||
body_binary.should == asset_binary | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require "spec_helper" | ||
require "prawnto/template_handlers/partials.rb" | ||
|
||
class PartialTester | ||
include Prawnto::TemplateHandlers::Partials | ||
end | ||
describe "Prawnto::TemplateHandlers::Partials" do | ||
subject do | ||
PartialTester.new | ||
end | ||
|
||
describe "#get_file_path" do | ||
before { Rails.stubs(:root).returns("") } | ||
|
||
it "should find partial in the same folder" do | ||
Dir.expects("[]").with("/app/views/test/_p1.{*.}prawn").returns("some/path") | ||
path = subject.send :get_file_path, "test/p1" | ||
end | ||
|
||
it "won't insert underscore if provided" do | ||
Dir.expects("[]").with("/app/views/test/_p1.{*.}prawn").returns("some/path") | ||
path = subject.send :get_file_path, "test/_p1" | ||
end | ||
|
||
it "should look in the current folder first" | ||
end | ||
|
||
describe "#partial_source" do | ||
end | ||
|
||
describe "render_partial" do | ||
end | ||
end |