From 6c91b699bf4c5b9288f8ac0136672d30e4989d7b Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 14 Apr 2011 12:23:21 +0200 Subject: The controller and resource generators will now automatically produce asset stubs (this can be turned off with --skip-assets). These stubs will use Coffee and Sass, if those libraries are available. [DHH] --- railties/test/generators/assets_generator_test.rb | 32 ++++++++++++++++++++++ .../test/generators/controller_generator_test.rb | 6 ++++ 2 files changed, 38 insertions(+) create mode 100644 railties/test/generators/assets_generator_test.rb (limited to 'railties/test') 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" -- cgit v1.2.3