aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@plataformatec.com.br>2014-08-05 13:59:41 +0200
committerJosé Valim <jose.valim@plataformatec.com.br>2014-08-05 14:04:30 +0200
commite5e4d08450642c77c5e4f8051d478663c57d97a3 (patch)
treeb00f21f4f9c4e7ee5c762bad197d8c9585f22e93 /railties/test/generators
parentd44702ee45219153c5e56da0a06ffe6ab5d14518 (diff)
downloadrails-e5e4d08450642c77c5e4f8051d478663c57d97a3.tar.gz
rails-e5e4d08450642c77c5e4f8051d478663c57d97a3.tar.bz2
rails-e5e4d08450642c77c5e4f8051d478663c57d97a3.zip
Bring back the helpers tests
Also keep the hook as other tools may rely on it, we just don't do anything by default on Rails.
Diffstat (limited to 'railties/test/generators')
-rw-r--r--railties/test/generators/helper_generator_test.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/railties/test/generators/helper_generator_test.rb b/railties/test/generators/helper_generator_test.rb
new file mode 100644
index 0000000000..add04f21a4
--- /dev/null
+++ b/railties/test/generators/helper_generator_test.rb
@@ -0,0 +1,39 @@
+require 'generators/generators_test_helper'
+require 'rails/generators/rails/helper/helper_generator'
+
+ObjectHelper = Class.new
+AnotherObjectHelperTest = Class.new
+
+class HelperGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
+ arguments %w(admin)
+
+ def test_helper_skeleton_is_created
+ run_generator
+ assert_file "app/helpers/admin_helper.rb", /module AdminHelper/
+ end
+
+ def test_check_class_collision
+ content = capture(:stderr){ run_generator ["object"] }
+ assert_match(/The name 'ObjectHelper' is either already used in your application or reserved/, content)
+ end
+
+ def test_namespaced_and_not_namespaced_helpers
+ run_generator ["products"]
+
+ # We have to require the generated helper to show the problem because
+ # the test helpers just check for generated files and contents but
+ # do not actually load them. But they have to be loaded (as in a real environment)
+ # to make the second generator run fail
+ require "#{destination_root}/app/helpers/products_helper"
+
+ assert_nothing_raised do
+ begin
+ run_generator ["admin::products"]
+ ensure
+ # cleanup
+ Object.send(:remove_const, :ProductsHelper)
+ end
+ end
+ end
+end