From 49c3ad7f7782274504fbe0818b9636d2b362a1a3 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sat, 25 Sep 2010 13:19:27 +0200 Subject: Add namespace for test_unit generators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- .../generators/test_unit/controller/templates/functional_test.rb | 2 ++ .../lib/rails/generators/test_unit/helper/templates/helper_test.rb | 2 ++ .../lib/rails/generators/test_unit/model/templates/unit_test.rb | 2 ++ railties/test/generators/namespaced_generators_test.rb | 6 +++--- 4 files changed, 9 insertions(+), 3 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb b/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb index 0d4185846d..11a73ebad7 100644 --- a/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb +++ b/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb @@ -1,5 +1,6 @@ require 'test_helper' +<% module_namespacing do -%> class <%= class_name %>ControllerTest < ActionController::TestCase <% if actions.empty? -%> # Replace this with your real tests. @@ -16,3 +17,4 @@ class <%= class_name %>ControllerTest < ActionController::TestCase <% end -%> <% end -%> end +<% end -%> diff --git a/railties/lib/rails/generators/test_unit/helper/templates/helper_test.rb b/railties/lib/rails/generators/test_unit/helper/templates/helper_test.rb index 591e40900e..7d37bda0f9 100644 --- a/railties/lib/rails/generators/test_unit/helper/templates/helper_test.rb +++ b/railties/lib/rails/generators/test_unit/helper/templates/helper_test.rb @@ -1,4 +1,6 @@ require 'test_helper' +<% module_namespacing do -%> class <%= class_name %>HelperTest < ActionView::TestCase end +<% end -%> diff --git a/railties/lib/rails/generators/test_unit/model/templates/unit_test.rb b/railties/lib/rails/generators/test_unit/model/templates/unit_test.rb index 3e0bc29d3a..6f79879838 100644 --- a/railties/lib/rails/generators/test_unit/model/templates/unit_test.rb +++ b/railties/lib/rails/generators/test_unit/model/templates/unit_test.rb @@ -1,8 +1,10 @@ require 'test_helper' +<% module_namespacing do -%> class <%= class_name %>Test < ActiveSupport::TestCase # Replace this with your real tests. test "the truth" do assert true end end +<% end -%> diff --git a/railties/test/generators/namespaced_generators_test.rb b/railties/test/generators/namespaced_generators_test.rb index a4e93a4ecc..4c85250e2c 100644 --- a/railties/test/generators/namespaced_generators_test.rb +++ b/railties/test/generators/namespaced_generators_test.rb @@ -26,7 +26,7 @@ class NamespacedControllerGeneratorTest < NamespacedGeneratorTestCase def test_namespaced_controller_skeleton_is_created run_generator assert_file "app/controllers/test_app/account_controller.rb", /module TestApp/, / class AccountController < ApplicationController/ - assert_file "test/functional/test_app/account_controller_test.rb", /TestApp::AccountController/ + assert_file "test/functional/test_app/account_controller_test.rb", /module TestApp/, / class AccountControllerTest/ end def test_skipping_namespace @@ -43,7 +43,7 @@ class NamespacedControllerGeneratorTest < NamespacedGeneratorTestCase def test_helpr_is_also_namespaced run_generator assert_file "app/helpers/test_app/account_helper.rb", /module TestApp/, / module AccountHelper/ - assert_file "test/unit/helpers/test_app/account_helper_test.rb", /TestApp::AccountHelper/ + assert_file "test/unit/helpers/test_app/account_helper_test.rb", /module TestApp/, / class AccountHelperTest/ end def test_invokes_default_test_framework @@ -124,7 +124,7 @@ class NamespacedModelGeneratorTest < NamespacedGeneratorTestCase def test_invokes_default_test_framework run_generator - assert_file "test/unit/test_app/account_test.rb", /class TestApp::AccountTest < ActiveSupport::TestCase/ + assert_file "test/unit/test_app/account_test.rb", /module TestApp/, /class AccountTest < ActiveSupport::TestCase/ assert_file "test/fixtures/test_app/accounts.yml", /name: MyString/, /age: 1/ end end -- cgit v1.2.3