Skip to content

Commit

Permalink
foo/xxx_test -> Foo::XxxTest, not FooTest::XxxTest
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed Nov 7, 2010
1 parent f9317ec commit 81db79f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/autotest/rails.rb
Expand Up @@ -80,7 +80,7 @@ def path_to_classname(s)
sep = File::SEPARATOR
parts = s.sub(/^test#{sep}((#{ignored_namespaces})#{sep})?/, '').sub(/\.rb$/, '').split(sep)
modules = parts.map { |path| path.split(/_/).map { |seg| seg.capitalize }.join }
modules = modules.map { |path| path =~ /Test$/ ? path : "#{path}Test" }
modules[-1] = "#{modules.last}Test" unless modules.last =~ /Test$/
modules.join('::')
end
end
8 changes: 6 additions & 2 deletions test/rails_test.rb
Expand Up @@ -15,11 +15,15 @@ class RailsTest < MiniTest::Unit::TestCase
end

it "should convert non-default namespaces" do
assert_equal "FooTest::PostControllerTest", @at.path_to_classname("test/foo/post_controller_test.rb")
assert_equal "Foo::PostControllerTest", @at.path_to_classname("test/foo/post_controller_test.rb")
end

it "should convert normal namespaces inside ignored namespaces" do
assert_equal "BloggingTest::PostControllerTest", @at.path_to_classname("test/controllers/blogging/post_controller_test.rb")
assert_equal "Blogging::PostControllerTest", @at.path_to_classname("test/controllers/blogging/post_controller_test.rb")
end

it "does not remove _test namespces" do
assert_equal "BloggingTest::PostControllerTest", @at.path_to_classname("test/controllers/blogging_test/post_controller_test.rb")
end
end
end
Expand Down

0 comments on commit 81db79f

Please sign in to comment.