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