1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Get rid of --old-style-hash

This commit is contained in:
José Valim 2011-12-20 17:51:26 +01:00
parent 500ca98fef
commit 9cf38be008
5 changed files with 6 additions and 58 deletions

View file

@ -60,9 +60,6 @@ module Rails
class_option :help, :type => :boolean, :aliases => "-h", :group => :rails,
:desc => "Show this help message and quit"
class_option :old_style_hash, :type => :boolean, :default => false,
:desc => "Force using old style hash (:foo => 'bar') on Ruby >= 1.9"
end
def initialize(*args)
@ -255,14 +252,9 @@ module Rails
create_file("#{destination}/.gitkeep") unless options[:skip_git]
end
# Returns Ruby 1.9 style key-value pair if current code is running on
# Ruby 1.9.x. Returns the old-style (with hash rocket) otherwise.
# Returns Ruby 1.9 style key-value pair.
def key_value(key, value)
if options[:old_style_hash] || RUBY_VERSION < '1.9'
":#{key} => #{value}"
else
"#{key}: #{value}"
end
"#{key}: #{value}"
end
end
end

View file

@ -9,9 +9,6 @@ module Rails
class_option :skip_namespace, :type => :boolean, :default => false,
:desc => "Skip namespace (affects only isolated applications)"
class_option :old_style_hash, :type => :boolean, :default => false,
:desc => "Force using old style hash (:foo => 'bar') on Ruby >= 1.9"
def initialize(args, *options) #:nodoc:
@inside_template = nil
# Unfreeze name in case it's given as a frozen string

View file

@ -337,18 +337,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
def test_new_hash_style
run_generator [destination_root]
assert_file "config/initializers/session_store.rb" do |file|
if RUBY_VERSION < "1.9"
assert_match(/config.session_store :cookie_store, :key => '_.+_session'/, file)
else
assert_match(/config.session_store :cookie_store, key: '_.+_session'/, file)
end
end
end
def test_force_old_style_hash
run_generator [destination_root, "--old-style-hash"]
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

View file

@ -77,33 +77,14 @@ class MailerGeneratorTest < Rails::Generators::TestCase
assert_file "app/mailers/notifier.rb" do |mailer|
assert_instance_method :foo, mailer do |foo|
if RUBY_VERSION < "1.9"
assert_match(/mail :to => "to@example.org"/, foo)
else
assert_match(/mail to: "to@example.org"/, foo)
end
assert_match(/mail to: "to@example.org"/, foo)
assert_match(/@greeting = "Hi"/, foo)
end
assert_instance_method :bar, mailer do |bar|
if RUBY_VERSION < "1.9"
assert_match(/mail :to => "to@example.org"/, bar)
else
assert_match(/mail to: "to@example.org"/, bar)
end
assert_match(/mail to: "to@example.org"/, bar)
assert_match(/@greeting = "Hi"/, bar)
end
end
end
def test_force_old_style_hash
run_generator ["notifier", "foo", "--old-style-hash"]
assert_file "app/mailers/notifier.rb" do |mailer|
assert_match(/default :from => "from@example.com"/, mailer)
assert_instance_method :foo, mailer do |foo|
assert_match(/mail :to => "to@example.org"/, foo)
end
end
end
end

View file

@ -126,18 +126,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
def test_new_hash_style
run_generator
assert_file "app/controllers/users_controller.rb" do |content|
if RUBY_VERSION < "1.9"
assert_match(/\{ render :action => "new" \}/, content)
else
assert_match(/\{ render action: "new" \}/, content)
end
end
end
def test_force_old_style_hash
run_generator ["User", "--old-style-hash"]
assert_file "app/controllers/users_controller.rb" do |content|
assert_match(/\{ render :action => "new" \}/, content)
assert_match(/\{ render action: "new" \}/, content)
end
end
end