aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators/app_generator_test.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2011-05-02 00:59:57 +0200
committerXavier Noria <fxn@hashref.com>2011-05-04 10:33:53 +0200
commitd9c39c3ae9aa9d0f50a4b557781be39e39e5b752 (patch)
treefeab3d5b27ae177f71cdcd043aadb5d8cb6bbf23 /railties/test/generators/app_generator_test.rb
parent5d2cdb190ad4eb35ab78180b2fd2e72a3d7a61f7 (diff)
downloadrails-d9c39c3ae9aa9d0f50a4b557781be39e39e5b752.tar.gz
rails-d9c39c3ae9aa9d0f50a4b557781be39e39e5b752.tar.bz2
rails-d9c39c3ae9aa9d0f50a4b557781be39e39e5b752.zip
restores the -j option, but now it accepts the name of any library
If passed "foo", a gem "foo-rails" is added to the Gemfile and "foo" and "foo_ujs" are required in the application JavaScript manifest.
Diffstat (limited to 'railties/test/generators/app_generator_test.rb')
-rw-r--r--railties/test/generators/app_generator_test.rb38
1 files changed, 29 insertions, 9 deletions
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 3cf92aed07..81263a6ce9 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -163,21 +163,41 @@ class AppGeneratorTest < Rails::Generators::TestCase
assert_file "config/application.rb", /#\s+require\s+["']active_record\/railtie["']/
end
- def test_jquery_and_test_unit_are_added_by_default
+ def test_creation_of_a_test_directory
run_generator
- assert_file "config/application.rb", /#\s+config\.action_view\.javascript_expansions\[:defaults\]\s+=\s+%w\(prototype effects dragdrop controls rails\)/
- assert_file "app/assets/javascripts/application.js"
- assert_file "vendor/assets/javascripts/jquery.js"
- assert_file "vendor/assets/javascripts/jquery_ujs.js"
- assert_file "test"
+ assert_file 'test'
+ end
+
+ def test_jquery_is_the_default_javascript_library
+ run_generator
+ assert_file "config/application.rb", /#\s+config\.action_view\.javascript_expansions\[:defaults\]\s+=\s+%w\(prototype prototype_ujs\)/
+ assert_file "app/assets/javascripts/application.js" do |contents|
+ assert_match %r{^//= require jquery}, contents
+ assert_match %r{^//= require jquery_ujs}, contents
+ end
+ assert_file 'Gemfile' do |contents|
+ assert_match /^gem 'jquery-rails'/, contents
+ end
+ end
+
+ def test_other_javascript_libraries
+ run_generator [destination_root, '-j', 'prototype']
+ assert_file "config/application.rb", /#\s+config\.action_view\.javascript_expansions\[:defaults\]\s+=\s+%w\(prototype prototype_ujs\)/
+ assert_file "app/assets/javascripts/application.js" do |contents|
+ assert_match %r{^//= require prototype}, contents
+ assert_match %r{^//= require prototype_ujs}, contents
+ end
+ assert_file 'Gemfile' do |contents|
+ assert_match /^gem 'prototype-rails'/, contents
+ end
end
def test_javascript_is_skipped_if_required
run_generator [destination_root, "--skip-javascript"]
assert_file "config/application.rb", /^\s+# config\.action_view\.javascript_expansions\[:defaults\]\s+=\s+%w\(\)/
- assert_file "app/assets/javascripts/application.js"
- assert_no_file "vendor/assets/javascripts/jquery.js"
- assert_no_file "vendor/assets/javascripts/jquery_ujs.js"
+ assert_file "app/assets/javascripts/application.js" do |contents|
+ assert_no_match %r{^//=\s+require\s}, contents
+ end
end
def test_template_from_dir_pwd