Permalink
Browse files

fixed tests to pass -- better coverage

  • Loading branch information...
1 parent 2eda351 commit fdbdcdd4fb3e769b6a651b96945aabefa6d4972e thorny_sun committed Dec 3, 2008
Showing with 16 additions and 14 deletions.
  1. +16 −14 test/action_controller_test.rb
@@ -1,36 +1,38 @@
require 'rubygems'
require 'action_controller'
+require 'action_controller/test_process'
require 'action_view'
require 'test/unit'
require File.dirname(__FILE__) + '/../lib/prawnto'
class ActionControllerTest < Test::Unit::TestCase
+ class PrawntoController < ActionController::Base
+ prawnto :inline=>true, :prawn=>{:page_orientation=>:landscape}
- def setup
- @controller_class = Class.new(ActionController::Base)
-
- # for some reason using the following as a block in the preceding statement is somehow different?
- @controller_class.module_eval do
- prawnto :inline=>true, :prawn=>{:page_orientation=>:landscape}
-
- def test
- prawnto :inline=>false, :prawn=>{:page_size=>'A4'}
- end
+ def test
+ prawnto :inline=>false, :prawn=>{:page_size=>'A4'}
end
end
def test_inheritable_options
- assert_equal({:page_orientation=>:landscape}, @controller_class.read_inheritable_attribute(:prawn))
- assert_equal({:inline=>true}, @controller_class.read_inheritable_attribute(:prawnto))
+ assert_equal({:page_orientation=>:landscape}, PrawntoController.read_inheritable_attribute(:prawn))
+ assert_equal({:inline=>true}, PrawntoController.read_inheritable_attribute(:prawnto))
end
def test_computed_options
- controller = @controller_class.new
- controller.test
+ controller = PrawntoController.new
+ test_process(controller)
assert_equal({:inline=>false, :prawn=>{:page_orientation=>:landscape, :page_size=>'A4'}}, controller.send(:compute_prawnto_options))
end
+protected
+ def test_process(controller, action = "test")
+ request = ActionController::TestRequest.new
+ request.action = action
+ controller.process(request, ActionController::TestResponse.new)
+ end
+
end

0 comments on commit fdbdcdd

Please sign in to comment.