0
@@ -3,19 +3,18 @@ require File.dirname(__FILE__) + '/test_helper'
0
require 'text_mate_mock'
0
require 'rails/rails_path'
0
-TextMate.line_number = '1'
0
-TextMate.column_number = '1'
0
-TextMate.project_directory = File.expand_path(File.dirname(__FILE__) + '/app_fixtures')
0
class RailsPathTest < Test::Unit::TestCase
0
+ TextMate.line_number = '1'
0
+ TextMate.column_number = '1'
0
+ TextMate.project_directory = File.expand_path(File.dirname(__FILE__) + '/app_fixtures')
0
@rp_controller = RailsPath.new(FIXTURE_PATH + '/app/controllers/user_controller.rb')
0
@rp_controller_with_module = RailsPath.new(FIXTURE_PATH + '/app/controllers/admin/base_controller.rb')
0
@rp_view = RailsPath.new(FIXTURE_PATH + '/app/views/user/new.rhtml')
0
@rp_view_with_module = RailsPath.new(FIXTURE_PATH + '/app/views/admin/base/action.rhtml')
0
@rp_fixture = RailsPath.new(FIXTURE_PATH + '/test/fixtures/users.yml')
0
@rp_fixture_spec = RailsPath.new(FIXTURE_PATH + '/spec/fixtures/users.yml')
0
- @rp_wacky = RailsPath.new(FIXTURE_PATH + '/wacky/users.yml')
0
+ @rp_wacky = RailsPath.new(FIXTURE_PATH + '/wacky/users.yml')
0
@@ -95,8 +94,8 @@ class RailsPathTest < Test::Unit::TestCase
0
def test_respond_to_format
0
current_file = RailsPath.new(FIXTURE_PATH + '/app/controllers/posts_controller.rb')
0
- TextMate.line_number = '13'
0
- assert_equal [12, 'js'], current_file.respond_to_format
0
+ TextMate.line_number = '14'
0
+ assert_equal [13, 'js'], current_file.respond_to_format
0
def test_rails_path_for
0
@@ -229,4 +228,62 @@ class RailsPathTest < Test::Unit::TestCase
0
assert_equal(:model, RailsPath.new(FIXTURE_PATH + '/app/views/notifier/forgot_password.html.erb').best_match)
0
assert_equal(:controller, RailsPath.new(FIXTURE_PATH + '/app/views/books/new.haml').best_match)
0
+ assert_equal false, @rp_view.wants_haml
0
+ haml_fixture_path = File.expand_path(File.dirname(__FILE__) + '/fixtures')
0
+ TextMate.project_directory = haml_fixture_path
0
+ assert_equal true, RailsPath.new(haml_fixture_path + '/app/views/posts/index.html.haml').wants_haml
0
+ TextMate.project_directory = File.expand_path(File.dirname(__FILE__) + '/app_fixtures')
0
+ haml_fixture_path = File.expand_path(File.dirname(__FILE__) + '/fixtures')
0
+ TextMate.project_directory = haml_fixture_path
0
+ assert_equal [], RailsPath.new(haml_fixture_path + '/public/stylesheets/sass/posts.sass').modules
0
+ assert_equal ["admin"], RailsPath.new(haml_fixture_path + '/public/stylesheets/sass/admin/posts.sass').modules
0
+ # Going from controller to view
0
+ current_file = RailsPath.new(haml_fixture_path + '/app/controllers/posts_controller.rb')
0
+ TextMate.line_number = '2'
0
+ assert_equal RailsPath.new(haml_fixture_path + '/app/views/posts/new.html.haml'), current_file.rails_path_for(:view)
0
+ current_file = RailsPath.new(haml_fixture_path + '/app/controllers/posts_controller.rb')
0
+ TextMate.line_number = '12'
0
+ assert_equal RailsPath.new(haml_fixture_path + '/app/views/posts/index.html.haml'), current_file.rails_path_for(:view)
0
+ current_file = RailsPath.new(haml_fixture_path + '/app/controllers/posts_controller.rb')
0
+ TextMate.line_number = '13'
0
+ assert_equal RailsPath.new(haml_fixture_path + '/app/views/posts/index.xml.builder'), current_file.rails_path_for(:view)
0
+ current_file = RailsPath.new(haml_fixture_path + '/app/controllers/posts_controller.rb')
0
+ TextMate.line_number = '14'
0
+ assert_equal RailsPath.new(haml_fixture_path + '/app/views/posts/index.js.rjs'), current_file.rails_path_for(:view)
0
+ current_file = RailsPath.new(haml_fixture_path + '/app/controllers/posts_controller.rb')
0
+ TextMate.line_number = '15'
0
+ assert_equal RailsPath.new(haml_fixture_path + '/app/views/posts/index.wacky.haml'), current_file.rails_path_for(:view)
0
+ # Going from view to controller
0
+ current_file = RailsPath.new(haml_fixture_path + '/app/views/posts/index.html.haml')
0
+ assert_equal RailsPath.new(haml_fixture_path + '/app/controllers/posts_controller.rb'), current_file.rails_path_for(:controller)
0
+ # Going from view to stylesheet
0
+ current_file = RailsPath.new(haml_fixture_path + '/app/views/posts/index.html.haml')
0
+ assert_equal RailsPath.new(haml_fixture_path + '/public/stylesheets/sass/posts.sass'), current_file.rails_path_for(:stylesheet)
0
+ # Going from stylesheet to helper
0
+ current_file = RailsPath.new(haml_fixture_path + '/public/stylesheets/sass/posts.sass')
0
+ assert_equal RailsPath.new(haml_fixture_path + '/app/helpers/posts_helper.rb'), current_file.rails_path_for(:helper)
0
+ TextMate.project_directory = File.expand_path(File.dirname(__FILE__) + '/app_fixtures')
0
\ No newline at end of file
Comments
No one has commented yet.