Chris@909: module TestHelper Chris@909: def self.report_location(path) Chris@909: [RAILS_ROOT + '/', 'vendor/plugins/'].each { |part| path.sub! part, ''} Chris@909: path = path.split('/') Chris@909: location, subject = path.first, path.last Chris@909: if subject.sub! '.rb', '' Chris@909: subject = subject.classify Chris@909: else Chris@909: subject.sub! '.html.erb', '' Chris@909: end Chris@909: "#{subject} (from #{location})" Chris@909: end Chris@909: Chris@909: def self.view_path_for path Chris@909: [RAILS_ROOT + '/', 'vendor/plugins/', '.html.erb'].each { |part| path.sub! part, ''} Chris@909: parts = path.split('/') Chris@909: parts[(parts.index('views')+1)..-1].join('/') Chris@909: end Chris@909: end Chris@909: Chris@909: class Test::Unit::TestCase Chris@909: # Add more helper methods to be used by all tests here... Chris@909: def get_action_on_controller(*args) Chris@909: action = args.shift Chris@909: with_controller *args Chris@909: get action Chris@909: end Chris@909: Chris@909: def with_controller(controller, namespace = nil) Chris@909: classname = controller.to_s.classify + 'Controller' Chris@909: classname = namespace.to_s.classify + '::' + classname unless namespace.nil? Chris@909: @controller = classname.constantize.new Chris@909: end Chris@909: Chris@909: def assert_response_body(expected) Chris@909: assert_equal expected, @response.body Chris@909: end Chris@909: end Chris@909: Chris@909: # Because we're testing this behaviour, we actually want these features on! Chris@909: Engines.disable_application_view_loading = false Chris@909: Engines.disable_application_code_loading = false