Permalink
Browse files

Cleanup the generators tests

  • Loading branch information...
1 parent cbd762e commit 3651b70451c40148002014edf209bc598e5d814b Rafael Mendonça França committed Nov 28, 2012
View
24 test/generators/generators_test_helper.rb
@@ -6,12 +6,6 @@
require 'rails/generators'
require 'rails/generators/test_case'
-module Rails
- def self.root
- @root ||= File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures'))
- end
-end
-
module TestApp
class Application < Rails::Application
end
@@ -20,21 +14,3 @@ class Application < Rails::Application
# Call configure to load the settings from
# Rails.application.config.generators to Rails::Generators
Rails.application.load_generators
-
-module GeneratorsTestHelper
- def self.included(base)
- base.class_eval do
- destination File.join(Rails.root, "tmp")
- setup :prepare_destination
-
- def teardown
- FileUtils.rm_rf(File.join(Rails.root, "tmp"))
- end
-
- begin
- base.tests Rails::Generators.const_get(base.name.sub(/Test$/, ''))
- rescue
- end
- end
- end
-end
View
10 test/generators/namespaced_generators_test.rb
@@ -1,11 +1,14 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/observer/observer_generator'
+require 'generators/rails/observer/observer_generator'
class NamespacedObserverGeneratorTest < Rails::Generators::TestCase
- include GeneratorsTestHelper
+ tests Rails::Generators::ObserverGenerator
+ arguments %w(account)
+ destination File.expand_path("../../tmp", __FILE__)
def setup
super
+ prepare_destination
Rails::Generators.namespace = TestApp
end
@@ -14,9 +17,6 @@ def teardown
Rails::Generators.namespace = nil
end
- arguments %w(account)
- tests Rails::Generators::ObserverGenerator
-
def test_invokes_default_orm
run_generator
assert_file "app/models/test_app/account_observer.rb", /module TestApp/, / class AccountObserver < ActiveRecord::Observer/
View
10 test/generators/observer_generator_test.rb
@@ -1,10 +1,16 @@
require 'generators/generators_test_helper'
-require 'rails/generators/rails/observer/observer_generator'
+require 'generators/rails/observer/observer_generator'
class ObserverGeneratorTest < Rails::Generators::TestCase
- include GeneratorsTestHelper
+ tests Rails::Generators::ObserverGenerator
+ destination File.expand_path("../../tmp", __FILE__)
arguments %w(account)
+ def setup
+ super
+ prepare_destination
+ end
+
def test_invokes_default_orm
run_generator
assert_file "app/models/account_observer.rb", /class AccountObserver < ActiveRecord::Observer/

0 comments on commit 3651b70

Please sign in to comment.