Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Cleanup the generators tests

  • Loading branch information...
commit 3651b70451c40148002014edf209bc598e5d814b 1 parent cbd762e
Rafael Mendonça França authored
24  test/generators/generators_test_helper.rb
@@ -6,12 +6,6 @@
6 6
 require 'rails/generators'
7 7
 require 'rails/generators/test_case'
8 8
 
9  
-module Rails
10  
-  def self.root
11  
-    @root ||= File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures'))
12  
-  end
13  
-end
14  
-
15 9
 module TestApp
16 10
   class Application < Rails::Application
17 11
   end
@@ -20,21 +14,3 @@ class Application < Rails::Application
20 14
 # Call configure to load the settings from
21 15
 # Rails.application.config.generators to Rails::Generators
22 16
 Rails.application.load_generators
23  
-
24  
-module GeneratorsTestHelper
25  
-  def self.included(base)
26  
-    base.class_eval do
27  
-      destination File.join(Rails.root, "tmp")
28  
-      setup :prepare_destination
29  
-
30  
-      def teardown
31  
-        FileUtils.rm_rf(File.join(Rails.root, "tmp"))
32  
-      end
33  
-
34  
-      begin
35  
-        base.tests Rails::Generators.const_get(base.name.sub(/Test$/, ''))
36  
-      rescue
37  
-      end
38  
-    end
39  
-  end
40  
-end
10  test/generators/namespaced_generators_test.rb
... ...
@@ -1,11 +1,14 @@
1 1
 require 'generators/generators_test_helper'
2  
-require 'rails/generators/rails/observer/observer_generator'
  2
+require 'generators/rails/observer/observer_generator'
3 3
 
4 4
 class NamespacedObserverGeneratorTest < Rails::Generators::TestCase
5  
-  include GeneratorsTestHelper
  5
+  tests Rails::Generators::ObserverGenerator
  6
+  arguments %w(account)
  7
+  destination File.expand_path("../../tmp", __FILE__)
6 8
 
7 9
   def setup
8 10
     super
  11
+    prepare_destination
9 12
     Rails::Generators.namespace = TestApp
10 13
   end
11 14
 
@@ -14,9 +17,6 @@ def teardown
14 17
     Rails::Generators.namespace = nil
15 18
   end
16 19
 
17  
-  arguments %w(account)
18  
-  tests Rails::Generators::ObserverGenerator
19  
-
20 20
   def test_invokes_default_orm
21 21
     run_generator
22 22
     assert_file "app/models/test_app/account_observer.rb", /module TestApp/, /  class AccountObserver < ActiveRecord::Observer/
10  test/generators/observer_generator_test.rb
... ...
@@ -1,10 +1,16 @@
1 1
 require 'generators/generators_test_helper'
2  
-require 'rails/generators/rails/observer/observer_generator'
  2
+require 'generators/rails/observer/observer_generator'
3 3
 
4 4
 class ObserverGeneratorTest < Rails::Generators::TestCase
5  
-  include GeneratorsTestHelper
  5
+  tests Rails::Generators::ObserverGenerator
  6
+  destination File.expand_path("../../tmp", __FILE__)
6 7
   arguments %w(account)
7 8
 
  9
+  def setup
  10
+    super
  11
+    prepare_destination
  12
+  end
  13
+
8 14
   def test_invokes_default_orm
9 15
     run_generator
10 16
     assert_file "app/models/account_observer.rb", /class AccountObserver < ActiveRecord::Observer/

0 notes on commit 3651b70

Please sign in to comment.
Something went wrong with that request. Please try again.