aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/generators/assets_generator_test.rb32
-rw-r--r--railties/test/generators/controller_generator_test.rb6
2 files changed, 38 insertions, 0 deletions
diff --git a/railties/test/generators/assets_generator_test.rb b/railties/test/generators/assets_generator_test.rb
new file mode 100644
index 0000000000..a2a40a28d4
--- /dev/null
+++ b/railties/test/generators/assets_generator_test.rb
@@ -0,0 +1,32 @@
+require 'generators/generators_test_helper'
+require 'rails/generators/rails/assets/assets_generator'
+
+# FOXME: Silence the 'Could not find task "using_coffee?"' message in tests due to the public stub
+class AssetsGeneratorTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
+ arguments %w(posts)
+
+ def test_vanilla_assets
+ run_generator
+ assert_file "app/assets/javascripts/posts.js"
+ assert_file "app/assets/stylesheets/posts.css"
+ end
+
+ def test_skipping_assets
+ content = run_generator ["posts", "--skip-assets"]
+ assert_no_file "app/assets/javascripts/posts.js"
+ assert_no_file "app/assets/stylesheets/posts.css"
+ end
+
+ def test_coffee_javascript
+ self.generator_class.any_instance.stubs(:using_coffee?).returns(true)
+ run_generator
+ assert_file "app/assets/javascripts/posts.js.coffee"
+ end
+
+ def test_sass_stylesheet
+ self.generator_class.any_instance.stubs(:using_sass?).returns(true)
+ run_generator
+ assert_file "app/assets/stylesheets/posts.css.scss"
+ end
+end
diff --git a/railties/test/generators/controller_generator_test.rb b/railties/test/generators/controller_generator_test.rb
index be99dc068d..655d8ad450 100644
--- a/railties/test/generators/controller_generator_test.rb
+++ b/railties/test/generators/controller_generator_test.rb
@@ -37,6 +37,12 @@ class ControllerGeneratorTest < Rails::Generators::TestCase
assert_no_file "test/unit/helpers/account_helper_test.rb"
end
+ def test_invokes_assets
+ run_generator
+ assert_file "app/assets/javascripts/account.js"
+ assert_file "app/assets/stylesheets/account.css"
+ end
+
def test_invokes_default_test_framework
run_generator
assert_file "test/functional/account_controller_test.rb"