diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2011-04-14 12:23:21 +0200 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2011-04-14 12:23:21 +0200 |
commit | 6c91b699bf4c5b9288f8ac0136672d30e4989d7b (patch) | |
tree | 7c6fd7b871f85a525503231d3270909ff3c67f32 /railties/test | |
parent | bd032fe97eabed62130bb745b0955090099fe525 (diff) | |
download | rails-6c91b699bf4c5b9288f8ac0136672d30e4989d7b.tar.gz rails-6c91b699bf4c5b9288f8ac0136672d30e4989d7b.tar.bz2 rails-6c91b699bf4c5b9288f8ac0136672d30e4989d7b.zip |
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]
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/generators/assets_generator_test.rb | 32 | ||||
-rw-r--r-- | railties/test/generators/controller_generator_test.rb | 6 |
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" |