Mercurial > hg > soundsoftware-site
comparison vendor/plugins/engines/test/lib/engines_test_helper.rb @ 0:513646585e45
* Import Redmine trunk SVN rev 3859
author | Chris Cannam |
---|---|
date | Fri, 23 Jul 2010 15:52:44 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:513646585e45 |
---|---|
1 module TestHelper | |
2 def self.report_location(path) | |
3 [RAILS_ROOT + '/', 'vendor/plugins/'].each { |part| path.sub! part, ''} | |
4 path = path.split('/') | |
5 location, subject = path.first, path.last | |
6 if subject.sub! '.rb', '' | |
7 subject = subject.classify | |
8 else | |
9 subject.sub! '.html.erb', '' | |
10 end | |
11 "#{subject} (from #{location})" | |
12 end | |
13 | |
14 def self.view_path_for path | |
15 [RAILS_ROOT + '/', 'vendor/plugins/', '.html.erb'].each { |part| path.sub! part, ''} | |
16 parts = path.split('/') | |
17 parts[(parts.index('views')+1)..-1].join('/') | |
18 end | |
19 end | |
20 | |
21 class Test::Unit::TestCase | |
22 # Add more helper methods to be used by all tests here... | |
23 def get_action_on_controller(*args) | |
24 action = args.shift | |
25 with_controller *args | |
26 get action | |
27 end | |
28 | |
29 def with_controller(controller, namespace = nil) | |
30 classname = controller.to_s.classify + 'Controller' | |
31 classname = namespace.to_s.classify + '::' + classname unless namespace.nil? | |
32 @controller = classname.constantize.new | |
33 end | |
34 | |
35 def assert_response_body(expected) | |
36 assert_equal expected, @response.body | |
37 end | |
38 end | |
39 | |
40 # Because we're testing this behaviour, we actually want these features on! | |
41 Engines.disable_application_view_loading = false | |
42 Engines.disable_application_code_loading = false |