annotate vendor/plugins/engines/test/lib/engines_test_helper.rb @ 8:0c83d98252d9 yuya

* Add custom repo prefix and proper auth realm, remove auth cache (seems like an unwise feature), pass DB handle around, various other bits of tidying
author Chris Cannam
date Thu, 12 Aug 2010 15:31:37 +0100
parents 513646585e45
children
rev   line source
Chris@0 1 module TestHelper
Chris@0 2 def self.report_location(path)
Chris@0 3 [RAILS_ROOT + '/', 'vendor/plugins/'].each { |part| path.sub! part, ''}
Chris@0 4 path = path.split('/')
Chris@0 5 location, subject = path.first, path.last
Chris@0 6 if subject.sub! '.rb', ''
Chris@0 7 subject = subject.classify
Chris@0 8 else
Chris@0 9 subject.sub! '.html.erb', ''
Chris@0 10 end
Chris@0 11 "#{subject} (from #{location})"
Chris@0 12 end
Chris@0 13
Chris@0 14 def self.view_path_for path
Chris@0 15 [RAILS_ROOT + '/', 'vendor/plugins/', '.html.erb'].each { |part| path.sub! part, ''}
Chris@0 16 parts = path.split('/')
Chris@0 17 parts[(parts.index('views')+1)..-1].join('/')
Chris@0 18 end
Chris@0 19 end
Chris@0 20
Chris@0 21 class Test::Unit::TestCase
Chris@0 22 # Add more helper methods to be used by all tests here...
Chris@0 23 def get_action_on_controller(*args)
Chris@0 24 action = args.shift
Chris@0 25 with_controller *args
Chris@0 26 get action
Chris@0 27 end
Chris@0 28
Chris@0 29 def with_controller(controller, namespace = nil)
Chris@0 30 classname = controller.to_s.classify + 'Controller'
Chris@0 31 classname = namespace.to_s.classify + '::' + classname unless namespace.nil?
Chris@0 32 @controller = classname.constantize.new
Chris@0 33 end
Chris@0 34
Chris@0 35 def assert_response_body(expected)
Chris@0 36 assert_equal expected, @response.body
Chris@0 37 end
Chris@0 38 end
Chris@0 39
Chris@0 40 # Because we're testing this behaviour, we actually want these features on!
Chris@0 41 Engines.disable_application_view_loading = false
Chris@0 42 Engines.disable_application_code_loading = false