diff --git a/Rakefile b/Rakefile index f465724..182ab22 100644 --- a/Rakefile +++ b/Rakefile @@ -4,7 +4,7 @@ Bundler::GemHelper.install_tasks require 'rake/testtask' desc 'Default: run unit tests.' -task :default => :test +task default: :test desc 'Run tests.' Rake::TestTask.new(:test) do |t| diff --git a/lib/i18n_alchemy.rb b/lib/i18n_alchemy.rb index bb339cb..4803fe4 100644 --- a/lib/i18n_alchemy.rb +++ b/lib/i18n_alchemy.rb @@ -20,7 +20,7 @@ def localized(attributes = nil) included do class_attribute :localized_methods, - :instance_reader => false, :instance_writer => false + instance_reader: false, instance_writer: false self.localized_methods = {} end diff --git a/lib/i18n_alchemy/date_parser.rb b/lib/i18n_alchemy/date_parser.rb index 77dfd7d..fd9cccc 100644 --- a/lib/i18n_alchemy/date_parser.rb +++ b/lib/i18n_alchemy/date_parser.rb @@ -28,7 +28,7 @@ def extract_date(parsed_date) end def i18n_format - I18n.t(:default, :scope => [i18n_scope, :formats]) + I18n.t(:default, scope: [i18n_scope, :formats]) end def i18n_scope diff --git a/lib/i18n_alchemy/numeric_parser.rb b/lib/i18n_alchemy/numeric_parser.rb index e37fb39..4e855fd 100644 --- a/lib/i18n_alchemy/numeric_parser.rb +++ b/lib/i18n_alchemy/numeric_parser.rb @@ -34,7 +34,7 @@ def separator end def translate(key) - I18n.t(key, :scope => :"number.format") + I18n.t(key, scope: :"number.format") end def valid_for_localization?(value) diff --git a/test/action_view_test.rb b/test/action_view_test.rb index e545da4..12e067f 100644 --- a/test/action_view_test.rb +++ b/test/action_view_test.rb @@ -5,11 +5,11 @@ class ActionViewTest < I18n::Alchemy::TestCase def setup @template = ActionView::Base.respond_to?(:empty) ? ActionView::Base.empty : ActionView::Base.new @product = Product.new( - :name => "Potato", - :quantity => 10, - :price => 1.99, - :released_at => Date.new(2011, 2, 28), - :last_sale_at => Time.mktime(2011, 2, 28, 13, 25, 30) + name: "Potato", + quantity: 10, + price: 1.99, + released_at: Date.new(2011, 2, 28), + last_sale_at: Time.mktime(2011, 2, 28, 13, 25, 30) ) @localized = @product.localized @@ -48,7 +48,7 @@ def assert_same_text_input(attribute, value) assert_includes [ text_input_sorted_attributes(attribute, value), text_input_unsorted_attributes(attribute, value) - ], @template.text_field(:product, attribute, :object => @localized) + ], @template.text_field(:product, attribute, object: @localized) end def text_input_sorted_attributes(attribute_name, value) diff --git a/test/custom_parsers/my_custom_date_parser.rb b/test/custom_parsers/my_custom_date_parser.rb index e273709..d4216d4 100644 --- a/test/custom_parsers/my_custom_date_parser.rb +++ b/test/custom_parsers/my_custom_date_parser.rb @@ -3,12 +3,12 @@ module MyCustomDateParser extend self def localize(value) - I18n.localize value, :format => :custom + I18n.localize value, format: :custom end protected def i18n_format - I18n.t(:custom, :scope => [:date, :formats]) + I18n.t(:custom, scope: [:date, :formats]) end end diff --git a/test/db/test_schema.rb b/test/db/test_schema.rb index b257274..d6cacad 100644 --- a/test/db/test_schema.rb +++ b/test/db/test_schema.rb @@ -1,6 +1,6 @@ ActiveRecord::Base.establish_connection( - :adapter => "sqlite3", - :database => ":memory:" + adapter: "sqlite3", + database: ":memory:" ) ActiveRecord::Schema.define do diff --git a/test/i18n_alchemy/proxy/attributes_parsing_test.rb b/test/i18n_alchemy/proxy/attributes_parsing_test.rb index 8bb3887..6222c4e 100644 --- a/test/i18n_alchemy/proxy/attributes_parsing_test.rb +++ b/test/i18n_alchemy/proxy/attributes_parsing_test.rb @@ -4,7 +4,7 @@ class ProxyAttributesParsingTest < I18n::Alchemy::ProxyTestCase # Attributes def test_initializes_proxy_with_attributes @localized = @product.localized( - :name => "Banana", :price => "0,99", :released_at => "28/02/2011") + name: "Banana", price: "0,99", released_at: "28/02/2011") assert_equal 0.99, @product.price assert_equal "0,99", @localized.price @@ -14,7 +14,7 @@ def test_initializes_proxy_with_attributes end def test_assign_attributes - @localized.assign_attributes(:price => '1,99') + @localized.assign_attributes(price: '1,99') assert_equal "1,99", @localized.price end @@ -31,7 +31,7 @@ def test_assign_attributes_does_not_change_given_attributes_hash end def test_attributes_assignment - @localized.attributes = { :price => '1,99' } + @localized.attributes = { price: '1,99' } assert_equal "1,99", @localized.price end @@ -42,7 +42,7 @@ def test_attributes_assignment_does_not_change_given_attributes_hash end def test_update - @localized.update(:price => '2,88') + @localized.update(price: '2,88') assert_equal '2,88', @localized.price assert_equal 2.88, @product.reload.price end @@ -54,13 +54,13 @@ def test_update_does_not_change_given_attributes_hash end def test_update_attributes - @localized.update_attributes(:price => '2,88') + @localized.update_attributes(price: '2,88') assert_equal '2,88', @localized.price assert_equal 2.88, @product.reload.price end def test_update! - @localized.update!(:price => '2,88') + @localized.update!(price: '2,88') assert_equal '2,88', @localized.price assert_equal 2.88, @product.reload.price end @@ -72,7 +72,7 @@ def test_update_bang_does_not_change_given_attributes_hash end def test_update_attributes! - @localized.update_attributes!(:price => '2,88') + @localized.update_attributes!(price: '2,88') assert_equal '2,88', @localized.price assert_equal 2.88, @product.reload.price end @@ -85,40 +85,40 @@ def test_update_attribute # Nested Attributes def test_should_assign_for_nested_attributes_for_collection_association - @supplier_localized.assign_attributes(:products_attributes => [{:price => '1,99'}, {:price => '2,93'}]) + @supplier_localized.assign_attributes(products_attributes: [{ price: '1,99' }, { price: '2,93' }]) assert_equal 2, @supplier_localized.products.size assert_equal '1,99', @supplier_localized.products.first.localized.price assert_equal '2,93', @supplier_localized.products.last.localized.price end def test_should_assign_for_nested_attributes_passing_a_hash_for_collection_with_unique_keys - @supplier_localized.assign_attributes(:products_attributes => {"0" => {:price => '2,93', "_destroy"=>"false"}, "1" => {:price => '2,85', "_destroy" => "false"}}) + @supplier_localized.assign_attributes(products_attributes: { '0' => { price: '2,93', _destroy: 'false' }, '1' => { price: '2,85', _destroy: 'false' }}) prices = @supplier.products.map { |p| p.localized.price }.sort assert_equal ['2,85', '2,93'], prices end def test_should_assign_for_nested_attributes_for_one_to_one_association - @supplier_localized.assign_attributes(:account_attributes => {:account_number => 10, :total_money => '100,87'}) + @supplier_localized.assign_attributes(account_attributes: { account_number: 10, total_money: '100,87' }) account = @supplier_localized.account assert_equal '10', account.account_number.to_s assert_equal '100,87', account.localized.total_money end def test_update_for_nested_attributes - @supplier_localized.update(:account_attributes => {:total_money => '99,87'}) + @supplier_localized.update(account_attributes: { total_money: '99,87' }) assert_equal '99,87', @supplier_localized.account.localized.total_money end def test_attributes_assignment_for_nested - @supplier_localized.attributes = {:account_attributes => {:total_money => '88,12'}} + @supplier_localized.attributes = { account_attributes: { total_money: '88,12' }} assert_equal '88,12', @supplier_localized.account.localized.total_money end private def assert_attributes_hash_is_unchanged - attributes = { :quantity => 1 } + attributes = { quantity: 1 } yield attributes - assert_equal({ :quantity => 1 }, attributes) + assert_equal({ quantity: 1 }, attributes) end end diff --git a/test/i18n_alchemy/proxy_test.rb b/test/i18n_alchemy/proxy_test.rb index 1edfcf0..ff3d9d8 100644 --- a/test/i18n_alchemy/proxy_test.rb +++ b/test/i18n_alchemy/proxy_test.rb @@ -3,7 +3,7 @@ class ProxyTest < I18n::Alchemy::ProxyTestCase def test_delegates_orm_methods_to_target_object assert @product.new_record? - assert @localized.save!(:name => "foo", :price => 1.99) + assert @localized.save!(name: "foo", price: 1.99) assert !@product.new_record? end diff --git a/test/models/product.rb b/test/models/product.rb index 3732684..c0522b1 100644 --- a/test/models/product.rb +++ b/test/models/product.rb @@ -1,9 +1,9 @@ class Product < ActiveRecord::Base include I18n::Alchemy - localize :total, :using => :number - localize :estimated_delivery_at, :using => :date - localize :estimated_last_comission_payment_at, :using => :timestamp - localize :released_month, :using => MyCustomDateParser + localize :total, using: :number + localize :estimated_delivery_at, using: :date + localize :estimated_last_comission_payment_at, using: :timestamp + localize :released_month, using: MyCustomDateParser belongs_to :supplier diff --git a/test/models/supplier.rb b/test/models/supplier.rb index 2aceae0..913e545 100644 --- a/test/models/supplier.rb +++ b/test/models/supplier.rb @@ -9,5 +9,5 @@ class Supplier < ActiveRecord::Base end class AnotherSupplier < Supplier - localize :created_at, :using => :timestamp + localize :created_at, using: :timestamp end \ No newline at end of file diff --git a/test/models/user.rb b/test/models/user.rb index 9f5861b..e36ae5f 100644 --- a/test/models/user.rb +++ b/test/models/user.rb @@ -2,5 +2,5 @@ class User include I18n::Alchemy attr_accessor :created_at - localize :created_at, :using => :date + localize :created_at, using: :date end