forked from GetJobber/prawnto
/
test_controller_spec.rb
60 lines (46 loc) · 1.66 KB
/
test_controller_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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
describe "complex headers" do
it "should return a file with a specified filename" do
get "/filename_test.pdf"
response.should be_success
response.header["Content-Disposition"].should == "attachment;filename=\"fancy_name.pdf\""
end
end
end