Skip to content

Commit

Permalink
Merge pull request #1124 from amatsuda/fix_railties_warnings
Browse files Browse the repository at this point in the history
Fix railties warnings
  • Loading branch information
josevalim committed May 18, 2011
2 parents 505defc + cce4615 commit f7df1f8
Show file tree
Hide file tree
Showing 17 changed files with 138 additions and 138 deletions.
6 changes: 3 additions & 3 deletions railties/lib/rails/engine.rb
Expand Up @@ -522,9 +522,9 @@ def load_seed
end end


initializer :append_assets_path do |app| initializer :append_assets_path do |app|
app.config.assets.paths.unshift *paths["vendor/assets"].existent app.config.assets.paths.unshift(*paths["vendor/assets"].existent)
app.config.assets.paths.unshift *paths["lib/assets"].existent app.config.assets.paths.unshift(*paths["lib/assets"].existent)
app.config.assets.paths.unshift *paths["app/assets"].existent app.config.assets.paths.unshift(*paths["app/assets"].existent)
end end


initializer :prepend_helpers_path do |app| initializer :prepend_helpers_path do |app|
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/generators/actions.rb
Expand Up @@ -278,7 +278,7 @@ def log(*args)
say args.first.to_s unless options.quiet? say args.first.to_s unless options.quiet?
else else
args << (self.behavior == :invoke ? :green : :red) args << (self.behavior == :invoke ? :green : :red)
say_status *args say_status(*args)
end end
end end


Expand Down
1 change: 1 addition & 0 deletions railties/lib/rails/generators/named_base.rb
Expand Up @@ -13,6 +13,7 @@ class NamedBase < Base
:desc => "Force using old style hash (:foo => 'bar') on Ruby >= 1.9" :desc => "Force using old style hash (:foo => 'bar') on Ruby >= 1.9"


def initialize(args, *options) #:nodoc: def initialize(args, *options) #:nodoc:
@inside_template = nil
# Unfreeze name in case it's given as a frozen string # Unfreeze name in case it's given as a frozen string
args[0] = args[0].dup if args[0].is_a?(String) && args[0].frozen? args[0] = args[0].dup if args[0].is_a?(String) && args[0].frozen?
super super
Expand Down
4 changes: 2 additions & 2 deletions railties/test/generators/actions_test.rb
Expand Up @@ -118,8 +118,8 @@ def test_environment_with_block_should_include_block_contents_in_environment_ini
end end


assert_file 'config/application.rb' do |content| assert_file 'config/application.rb' do |content|
assert_match /# This will be added/, content assert_match(/# This will be added/, content)
assert_no_match /# This wont be added/, content assert_no_match(/# This wont be added/, content)
end end
end end


Expand Down
26 changes: 13 additions & 13 deletions railties/test/generators/app_generator_test.rb
Expand Up @@ -155,7 +155,7 @@ def test_generator_if_skip_active_record_is_given
run_generator [destination_root, "--skip-active-record"] run_generator [destination_root, "--skip-active-record"]
assert_no_file "config/database.yml" assert_no_file "config/database.yml"
assert_file "test/test_helper.rb" do |helper_content| assert_file "test/test_helper.rb" do |helper_content|
assert_no_match /fixtures :all/, helper_content assert_no_match(/fixtures :all/, helper_content)
end end
assert_file "test/performance/browsing_test.rb" assert_file "test/performance/browsing_test.rb"
end end
Expand All @@ -178,7 +178,7 @@ def test_jquery_is_the_default_javascript_library
assert_match %r{^//= require jquery_ujs}, contents assert_match %r{^//= require jquery_ujs}, contents
end end
assert_file 'Gemfile' do |contents| assert_file 'Gemfile' do |contents|
assert_match /^gem 'jquery-rails'/, contents assert_match(/^gem 'jquery-rails'/, contents)
end end
end end


Expand All @@ -190,7 +190,7 @@ def test_other_javascript_libraries
assert_match %r{^//= require prototype_ujs}, contents assert_match %r{^//= require prototype_ujs}, contents
end end
assert_file 'Gemfile' do |contents| assert_file 'Gemfile' do |contents|
assert_match /^gem 'prototype-rails'/, contents assert_match(/^gem 'prototype-rails'/, contents)
end end
end end


Expand All @@ -205,35 +205,35 @@ def test_javascript_is_skipped_if_required
def test_inclusion_of_turn_gem_in_gemfile def test_inclusion_of_turn_gem_in_gemfile
run_generator run_generator
assert_file "Gemfile" do |contents| assert_file "Gemfile" do |contents|
assert_match /gem 'turn'/, contents unless RUBY_VERSION < '1.9.2' assert_match(/gem 'turn'/, contents) unless RUBY_VERSION < '1.9.2'
assert_no_match /gem 'turn'/, contents if RUBY_VERSION < '1.9.2' assert_no_match(/gem 'turn'/, contents) if RUBY_VERSION < '1.9.2'
end end
end end


def test_turn_gem_is_not_included_in_gemfile_if_skipping_test_unit def test_turn_gem_is_not_included_in_gemfile_if_skipping_test_unit
run_generator [destination_root, "--skip-test-unit"] run_generator [destination_root, "--skip-test-unit"]
assert_file "Gemfile" do |contents| assert_file "Gemfile" do |contents|
assert_no_match /gem 'turn'/, contents unless RUBY_VERSION < '1.9.2' assert_no_match(/gem 'turn'/, contents) unless RUBY_VERSION < '1.9.2'
end end
end end


def test_inclusion_of_ruby_debug def test_inclusion_of_ruby_debug
run_generator run_generator
assert_file "Gemfile" do |contents| assert_file "Gemfile" do |contents|
assert_match /gem 'ruby-debug'/, contents if RUBY_VERSION < '1.9' assert_match(/gem 'ruby-debug'/, contents) if RUBY_VERSION < '1.9'
end end
end end


def test_inclusion_of_ruby_debug19_if_ruby19 def test_inclusion_of_ruby_debug19_if_ruby19
run_generator run_generator
assert_file "Gemfile" do |contents| assert_file "Gemfile" do |contents|
assert_match /gem 'ruby-debug19', :require => 'ruby-debug'/, contents unless RUBY_VERSION < '1.9' assert_match(/gem 'ruby-debug19', :require => 'ruby-debug'/, contents) unless RUBY_VERSION < '1.9'
end end
end end


def test_template_from_dir_pwd def test_template_from_dir_pwd
FileUtils.cd(Rails.root) FileUtils.cd(Rails.root)
assert_match /It works from file!/, run_generator([destination_root, "-m", "lib/template.rb"]) assert_match(/It works from file!/, run_generator([destination_root, "-m", "lib/template.rb"]))
end end


def test_usage_read_from_file def test_usage_read_from_file
Expand All @@ -243,7 +243,7 @@ def test_usage_read_from_file


def test_default_usage def test_default_usage
File.expects(:exist?).returns(false) File.expects(:exist?).returns(false)
assert_match /Create rails files for app generator/, Rails::Generators::AppGenerator.desc assert_match(/Create rails files for app generator/, Rails::Generators::AppGenerator.desc)
end end


def test_default_namespace def test_default_namespace
Expand All @@ -270,17 +270,17 @@ def test_new_hash_style
run_generator [destination_root] run_generator [destination_root]
assert_file "config/initializers/session_store.rb" do |file| assert_file "config/initializers/session_store.rb" do |file|
if RUBY_VERSION < "1.9" if RUBY_VERSION < "1.9"
assert_match /config.session_store :cookie_store, :key => '_.+_session'/, file assert_match(/config.session_store :cookie_store, :key => '_.+_session'/, file)
else else
assert_match /config.session_store :cookie_store, key: '_.+_session'/, file assert_match(/config.session_store :cookie_store, key: '_.+_session'/, file)
end end
end end
end end


def test_force_old_style_hash def test_force_old_style_hash
run_generator [destination_root, "--old-style-hash"] run_generator [destination_root, "--old-style-hash"]
assert_file "config/initializers/session_store.rb" do |file| assert_file "config/initializers/session_store.rb" do |file|
assert_match /config.session_store :cookie_store, :key => '_.+_session'/, file assert_match(/config.session_store :cookie_store, :key => '_.+_session'/, file)
end end
end end


Expand Down
4 changes: 2 additions & 2 deletions railties/test/generators/controller_generator_test.rb
Expand Up @@ -9,7 +9,7 @@ class ControllerGeneratorTest < Rails::Generators::TestCase


def test_help_does_not_show_invoked_generators_options_if_they_already_exist def test_help_does_not_show_invoked_generators_options_if_they_already_exist
content = run_generator ["--help"] content = run_generator ["--help"]
assert_no_match /Helper options\:/, content assert_no_match(/Helper options\:/, content)
end end


def test_controller_skeleton_is_created def test_controller_skeleton_is_created
Expand All @@ -20,7 +20,7 @@ def test_controller_skeleton_is_created
def test_check_class_collision def test_check_class_collision
Object.send :const_set, :ObjectController, Class.new Object.send :const_set, :ObjectController, Class.new
content = capture(:stderr){ run_generator ["object"] } content = capture(:stderr){ run_generator ["object"] }
assert_match /The name 'ObjectController' is either already used in your application or reserved/, content assert_match(/The name 'ObjectController' is either already used in your application or reserved/, content)
ensure ensure
Object.send :remove_const, :ObjectController Object.send :remove_const, :ObjectController
end end
Expand Down
6 changes: 3 additions & 3 deletions railties/test/generators/helper_generator_test.rb
Expand Up @@ -20,17 +20,17 @@ def test_invokes_default_test_framework


def test_logs_if_the_test_framework_cannot_be_found def test_logs_if_the_test_framework_cannot_be_found
content = run_generator ["admin", "--test-framework=rspec"] content = run_generator ["admin", "--test-framework=rspec"]
assert_match /rspec \[not found\]/, content assert_match(/rspec \[not found\]/, content)
end end


def test_check_class_collision def test_check_class_collision
content = capture(:stderr){ run_generator ["object"] } content = capture(:stderr){ run_generator ["object"] }
assert_match /The name 'ObjectHelper' is either already used in your application or reserved/, content assert_match(/The name 'ObjectHelper' is either already used in your application or reserved/, content)
end end


def test_check_class_collision_on_tests def test_check_class_collision_on_tests
content = capture(:stderr){ run_generator ["another_object"] } content = capture(:stderr){ run_generator ["another_object"] }
assert_match /The name 'AnotherObjectHelperTest' is either already used in your application or reserved/, content assert_match(/The name 'AnotherObjectHelperTest' is either already used in your application or reserved/, content)
end end


def test_namespaced_and_not_namespaced_helpers def test_namespaced_and_not_namespaced_helpers
Expand Down
48 changes: 24 additions & 24 deletions railties/test/generators/mailer_generator_test.rb
Expand Up @@ -9,47 +9,47 @@ class MailerGeneratorTest < Rails::Generators::TestCase
def test_mailer_skeleton_is_created def test_mailer_skeleton_is_created
run_generator run_generator
assert_file "app/mailers/notifier.rb" do |mailer| assert_file "app/mailers/notifier.rb" do |mailer|
assert_match /class Notifier < ActionMailer::Base/, mailer assert_match(/class Notifier < ActionMailer::Base/, mailer)
if RUBY_VERSION < "1.9" if RUBY_VERSION < "1.9"
assert_match /default :from => "from@example.com"/, mailer assert_match(/default :from => "from@example.com"/, mailer)
else else
assert_match /default from: "from@example.com"/, mailer assert_match(/default from: "from@example.com"/, mailer)
end end
end end
end end


def test_mailer_with_i18n_helper def test_mailer_with_i18n_helper
run_generator run_generator
assert_file "app/mailers/notifier.rb" do |mailer| assert_file "app/mailers/notifier.rb" do |mailer|
assert_match /en\.notifier\.foo\.subject/, mailer assert_match(/en\.notifier\.foo\.subject/, mailer)
assert_match /en\.notifier\.bar\.subject/, mailer assert_match(/en\.notifier\.bar\.subject/, mailer)
end end
end end


def test_check_class_collision def test_check_class_collision
content = capture(:stderr){ run_generator ["object"] } content = capture(:stderr){ run_generator ["object"] }
assert_match /The name 'Object' is either already used in your application or reserved/, content assert_match(/The name 'Object' is either already used in your application or reserved/, content)
end end


def test_invokes_default_test_framework def test_invokes_default_test_framework
run_generator run_generator
assert_file "test/functional/notifier_test.rb" do |test| assert_file "test/functional/notifier_test.rb" do |test|
assert_match /class NotifierTest < ActionMailer::TestCase/, test assert_match(/class NotifierTest < ActionMailer::TestCase/, test)
assert_match /test "foo"/, test assert_match(/test "foo"/, test)
assert_match /test "bar"/, test assert_match(/test "bar"/, test)
end end
end end


def test_invokes_default_template_engine def test_invokes_default_template_engine
run_generator run_generator
assert_file "app/views/notifier/foo.text.erb" do |view| assert_file "app/views/notifier/foo.text.erb" do |view|
assert_match %r(app/views/notifier/foo\.text\.erb), view assert_match(%r(app/views/notifier/foo\.text\.erb), view)
assert_match /<%= @greeting %>/, view assert_match(/<%= @greeting %>/, view)
end end


assert_file "app/views/notifier/bar.text.erb" do |view| assert_file "app/views/notifier/bar.text.erb" do |view|
assert_match %r(app/views/notifier/bar\.text\.erb), view assert_match(%r(app/views/notifier/bar\.text\.erb), view)
assert_match /<%= @greeting %>/, view assert_match(/<%= @greeting %>/, view)
end end
end end


Expand All @@ -60,14 +60,14 @@ def test_invokes_default_template_engine_even_with_no_action


def test_logs_if_the_template_engine_cannot_be_found def test_logs_if_the_template_engine_cannot_be_found
content = run_generator ["notifier", "foo", "bar", "--template-engine=haml"] content = run_generator ["notifier", "foo", "bar", "--template-engine=haml"]
assert_match /haml \[not found\]/, content assert_match(/haml \[not found\]/, content)
end end


def test_mailer_with_namedspaced_mailer def test_mailer_with_namedspaced_mailer
run_generator ["Farm::Animal", "moos"] run_generator ["Farm::Animal", "moos"]
assert_file "app/mailers/farm/animal.rb" do |mailer| assert_file "app/mailers/farm/animal.rb" do |mailer|
assert_match /class Farm::Animal < ActionMailer::Base/, mailer assert_match(/class Farm::Animal < ActionMailer::Base/, mailer)
assert_match /en\.farm\.animal\.moos\.subject/, mailer assert_match(/en\.farm\.animal\.moos\.subject/, mailer)
end end
assert_file "app/views/farm/animal/moos.text.erb" assert_file "app/views/farm/animal/moos.text.erb"
end end
Expand All @@ -78,31 +78,31 @@ def test_actions_are_turned_into_methods
assert_file "app/mailers/notifier.rb" do |mailer| assert_file "app/mailers/notifier.rb" do |mailer|
assert_instance_method :foo, mailer do |foo| assert_instance_method :foo, mailer do |foo|
if RUBY_VERSION < "1.9" if RUBY_VERSION < "1.9"
assert_match /mail :to => "to@example.org"/, foo assert_match(/mail :to => "to@example.org"/, foo)
else else
assert_match /mail to: "to@example.org"/, foo assert_match(/mail to: "to@example.org"/, foo)
end end
assert_match /@greeting = "Hi"/, foo assert_match(/@greeting = "Hi"/, foo)
end end


assert_instance_method :bar, mailer do |bar| assert_instance_method :bar, mailer do |bar|
if RUBY_VERSION < "1.9" if RUBY_VERSION < "1.9"
assert_match /mail :to => "to@example.org"/, bar assert_match(/mail :to => "to@example.org"/, bar)
else else
assert_match /mail to: "to@example.org"/, bar assert_match(/mail to: "to@example.org"/, bar)
end end
assert_match /@greeting = "Hi"/, bar assert_match(/@greeting = "Hi"/, bar)
end end
end end
end end


def test_force_old_style_hash def test_force_old_style_hash
run_generator ["notifier", "foo", "--old-style-hash"] run_generator ["notifier", "foo", "--old-style-hash"]
assert_file "app/mailers/notifier.rb" do |mailer| assert_file "app/mailers/notifier.rb" do |mailer|
assert_match /default :from => "from@example.com"/, mailer assert_match(/default :from => "from@example.com"/, mailer)


assert_instance_method :foo, mailer do |foo| assert_instance_method :foo, mailer do |foo|
assert_match /mail :to => "to@example.org"/, foo assert_match(/mail :to => "to@example.org"/, foo)
end end
end end
end end
Expand Down
16 changes: 8 additions & 8 deletions railties/test/generators/migration_generator_test.rb
Expand Up @@ -35,8 +35,8 @@ def test_add_migration_with_attributes


assert_migration "db/migrate/#{migration}.rb" do |content| assert_migration "db/migrate/#{migration}.rb" do |content|
assert_method :change, content do |up| assert_method :change, content do |up|
assert_match /add_column :posts, :title, :string/, up assert_match(/add_column :posts, :title, :string/, up)
assert_match /add_column :posts, :body, :text/, up assert_match(/add_column :posts, :body, :text/, up)
end end
end end
end end
Expand All @@ -47,13 +47,13 @@ def test_remove_migration_with_attributes


assert_migration "db/migrate/#{migration}.rb" do |content| assert_migration "db/migrate/#{migration}.rb" do |content|
assert_method :up, content do |up| assert_method :up, content do |up|
assert_match /remove_column :posts, :title/, up assert_match(/remove_column :posts, :title/, up)
assert_match /remove_column :posts, :body/, up assert_match(/remove_column :posts, :body/, up)
end end


assert_method :down, content do |down| assert_method :down, content do |down|
assert_match /add_column :posts, :title, :string/, down assert_match(/add_column :posts, :title, :string/, down)
assert_match /add_column :posts, :body, :text/, down assert_match(/add_column :posts, :body, :text/, down)
end end
end end
end end
Expand All @@ -64,11 +64,11 @@ def test_should_create_empty_migrations_if_name_not_start_with_add_or_remove


assert_migration "db/migrate/#{migration}.rb" do |content| assert_migration "db/migrate/#{migration}.rb" do |content|
assert_method :up, content do |up| assert_method :up, content do |up|
assert_match /^\s*$/, up assert_match(/^\s*$/, up)
end end


assert_method :down, content do |down| assert_method :down, content do |down|
assert_match /^\s*$/, down assert_match(/^\s*$/, down)
end end
end end
end end
Expand Down

0 comments on commit f7df1f8

Please sign in to comment.