Permalink
Browse files

Convert to 1.9 hash syntax

  • Loading branch information...
1 parent b999889 commit fcbb5c485e5e5f77fed18c190e718e8b97b90e76 @mcmire mcmire committed Jan 17, 2014
Showing with 463 additions and 463 deletions.
  1. +2 −2 features/step_definitions/rails_steps.rb
  2. +1 −1 lib/shoulda/matchers/action_controller.rb
  3. +3 −3 lib/shoulda/matchers/action_controller/render_template_matcher.rb
  4. +11 −11 lib/shoulda/matchers/action_controller/route_matcher.rb
  5. +1 −1 lib/shoulda/matchers/action_controller/route_params.rb
  6. +1 −1 lib/shoulda/matchers/active_model.rb
  7. +4 −4 lib/shoulda/matchers/active_model/allow_value_matcher.rb
  8. +8 −8 lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb
  9. +5 −5 lib/shoulda/matchers/active_model/helpers.rb
  10. +2 −2 lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb
  11. +2 −2 lib/shoulda/matchers/active_record/association_matcher.rb
  12. +1 −1 lib/shoulda/matchers/active_record/have_db_column_matcher.rb
  13. +1 −1 spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
  14. +12 −12 spec/shoulda/matchers/action_controller/render_template_matcher_spec.rb
  15. +4 −4 spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
  16. +3 −3 spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
  17. +10 −10 spec/shoulda/matchers/action_controller/route_matcher_spec.rb
  18. +4 −4 spec/shoulda/matchers/action_controller/route_params_spec.rb
  19. +8 −8 spec/shoulda/matchers/action_controller/set_session_matcher_spec.rb
  20. +16 −16 spec/shoulda/matchers/action_controller/set_the_flash_matcher_spec.rb
  21. +10 −10 spec/shoulda/matchers/active_model/allow_mass_assignment_of_matcher_spec.rb
  22. +20 −20 spec/shoulda/matchers/active_model/allow_value_matcher_spec.rb
  23. +12 −12 spec/shoulda/matchers/active_model/disallow_value_matcher_spec.rb
  24. +11 −11 spec/shoulda/matchers/active_model/ensure_exclusion_of_matcher_spec.rb
  25. +31 −31 spec/shoulda/matchers/active_model/ensure_inclusion_of_matcher_spec.rb
  26. +23 −23 spec/shoulda/matchers/active_model/ensure_length_of_matcher_spec.rb
  27. +12 −12 spec/shoulda/matchers/active_model/exception_message_finder_spec.rb
  28. +23 −23 spec/shoulda/matchers/active_model/helpers_spec.rb
  29. +14 −14 spec/shoulda/matchers/active_model/numericality_matchers/odd_even_number_matcher_spec.rb
  30. +6 −6 spec/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher_spec.rb
  31. +4 −4 spec/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb
  32. +4 −4 spec/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb
  33. +13 −13 spec/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb
  34. +13 −13 spec/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb
  35. +9 −9 spec/shoulda/matchers/active_model/validation_message_finder_spec.rb
  36. +12 −12 spec/shoulda/matchers/active_record/accept_nested_attributes_for_matcher_spec.rb
  37. +105 −105 spec/shoulda/matchers/active_record/association_matcher_spec.rb
  38. +27 −27 spec/shoulda/matchers/active_record/have_db_column_matcher_spec.rb
  39. +4 −4 spec/shoulda/matchers/active_record/have_db_index_matcher_spec.rb
  40. +4 −4 spec/shoulda/matchers/active_record/have_readonly_attributes_matcher_spec.rb
  41. +2 −2 spec/shoulda/matchers/active_record/serialize_matcher_spec.rb
  42. +2 −2 spec/support/activemodel_helpers.rb
  43. +2 −2 spec/support/controller_builder.rb
  44. +1 −1 spec/support/model_builder.rb
@@ -33,14 +33,14 @@
end
When /^I configure the application to use "([^\"]+)" from this project$/ do |name|
- append_to_gemfile "gem '#{name}', :path => '#{PROJECT_ROOT}'"
+ append_to_gemfile "gem '#{name}', path: '#{PROJECT_ROOT}'"
steps %{And I install gems}
end
When /^I configure the application to use "([^\"]+)" from this project in test and development$/ do |name|
append_to_gemfile <<-GEMFILE
group :test, :development do
- gem '#{name}', :path => '#{PROJECT_ROOT}'
+ gem '#{name}', path: '#{PROJECT_ROOT}'
end
GEMFILE
steps %{And I install gems}
@@ -18,7 +18,7 @@ module Matchers
#
# describe UsersController, 'on GET to show with a valid id' do
# before(:each) do
- # get :show, :id => User.first.to_param
+ # get :show, id: User.first.to_param
# end
#
# it { should respond_with(:success) }
@@ -8,13 +8,13 @@ module ActionController # :nodoc:
# it { should render_template(:show) }
#
# assert that the "_customer" partial was rendered
- # it { should render_template(:partial => '_customer') }
+ # it { should render_template(partial: '_customer') }
#
# assert that the "_customer" partial was rendered twice
- # it { should render_template(:partial => '_customer', :count => 2) }
+ # it { should render_template(partial: '_customer', count: 2) }
#
# assert that no partials were rendered
- # it { should render_template(:partial => false) }
+ # it { should render_template(partial: false) }
def render_template(options = {}, message = nil)
RenderTemplateMatcher.new(options, message, self)
end
@@ -12,20 +12,20 @@ module ActionController # :nodoc:
# Examples:
#
# it { should route(:get, '/posts').
- # to(:controller => :posts, :action => :index) }
+ # to(controller: :posts, action: :index) }
# it { should route(:get, '/posts').to('posts#index') }
- # it { should route(:get, '/posts/new').to(:action => :new) }
- # it { should route(:post, '/posts').to(:action => :create) }
- # it { should route(:get, '/posts/1').to(:action => :show, :id => 1) }
- # it { should route(:get, '/posts/1').to('posts#show', :id => 1) }
- # it { should route(:get, '/posts/1/edit').to(:action => :edit, :id => 1) }
- # it { should route(:put, '/posts/1').to(:action => :update, :id => 1) }
+ # it { should route(:get, '/posts/new').to(action: :new) }
+ # it { should route(:post, '/posts').to(action: :create) }
+ # it { should route(:get, '/posts/1').to(action: :show, id: 1) }
+ # it { should route(:get, '/posts/1').to('posts#show', id: 1) }
+ # it { should route(:get, '/posts/1/edit').to(action: :edit, id: 1) }
+ # it { should route(:put, '/posts/1').to(action: :update, id: 1) }
# it { should route(:delete, '/posts/1').
- # to(:action => :destroy, :id => 1) }
+ # to(action: :destroy, id: 1) }
# it { should route(:get, '/users/1/posts/1').
- # to(:action => :show, :id => 1, :user_id => 1) }
+ # to(action: :show, id: 1, user_id: 1) }
# it { should route(:get, '/users/1/posts/1').
- # to('posts#show', :id => 1, :user_id => 1) }
+ # to('posts#show', id: 1, user_id: 1) }
def route(method, path)
RouteMatcher.new(method, path, self)
end
@@ -71,7 +71,7 @@ def guess_controller!(controller)
def route_recognized?
begin
@context.send(:assert_routing,
- { :method => @method, :path => @path },
+ { method: @method, path: @path },
@params)
@failure_message_when_negated = "Didn't expect to #{description}"
@@ -25,7 +25,7 @@ def controller_and_action_given_as_string?
def extract_params_from_string
params = args[1] || {}
controller, action = args[0].split('#')
- params.merge!(:controller => controller, :action => action)
+ params.merge!(controller: controller, action: action)
end
def stringify_params
@@ -44,7 +44,7 @@ module Matchers
# class User < ActiveRecord::Base
# validates_presence_of :name
# validates_presence_of :phone_number
- # validates_inclusion_of :status, :in => %w(Activated Pending), :strict => true
+ # validates_inclusion_of :status, in: %w(Activated Pending), strict: true
# attr_accessible :name, :phone_number
# end
module ActiveModel
@@ -13,7 +13,7 @@ module ActiveModel # :nodoc:
# the test looks for any errors in <tt>errors.on(:attribute)</tt>.
# * <tt>strict</tt> - expects the model to raise an exception when the
# validation fails rather than adding to the errors collection. Used for
- # testing `validates!` and the `:strict => true` validation options.
+ # testing `validates!` and the `strict: true` validation options.
#
# Example:
# it { should_not allow_value('bad').for(:isbn) }
@@ -163,9 +163,9 @@ def default_expected_message
def default_attribute_message
default_error_message(
options[:expected_message],
- :model_name => model_name,
- :instance => instance,
- :attribute => attribute_to_set
+ model_name: model_name,
+ instance: instance,
+ attribute: attribute_to_set
)
end
@@ -110,18 +110,18 @@ def matches?(subject)
def translate_messages!
if Symbol === @short_message
@short_message = default_error_message(@short_message,
- :model_name => @subject.class.to_s.underscore,
- :instance => @subject,
- :attribute => @attribute,
- :count => @options[:minimum])
+ model_name: @subject.class.to_s.underscore,
+ instance: @subject,
+ attribute: @attribute,
+ count: @options[:minimum])
end
if Symbol === @long_message
@long_message = default_error_message(@long_message,
- :model_name => @subject.class.to_s.underscore,
- :instance => @subject,
- :attribute => @attribute,
- :count => @options[:maximum])
+ model_name: @subject.class.to_s.underscore,
+ instance: @subject,
+ attribute: @attribute,
+ count: @options[:maximum])
end
end
@@ -19,10 +19,10 @@ def pretty_error_messages(obj) # :nodoc:
# instance is given.
#
# default_error_message(:blank)
- # default_error_message(:too_short, :count => 5)
- # default_error_message(:too_long, :count => 60)
- # default_error_message(:blank, :model_name => 'user', :attribute => 'name')
- # default_error_message(:blank, :instance => #<Model>, :attribute => 'name')
+ # default_error_message(:too_short, count: 5)
+ # default_error_message(:too_long, count: 60)
+ # default_error_message(:blank, model_name: 'user', attribute: 'name')
+ # default_error_message(:blank, instance: #<Model>, attribute: 'name')
def default_error_message(key, options = {})
model_name = options.delete(:model_name)
attribute = options.delete(:attribute)
@@ -36,7 +36,7 @@ def default_error_message(key, options = {})
:"errors.attributes.#{attribute}.#{key}",
:"errors.messages.#{key}" ]
I18n.translate(:"activerecord.errors.models.#{model_name}.attributes.#{attribute}.#{key}",
- { :default => default_translation }.merge(options))
+ { default: default_translation }.merge(options))
end
end
end
@@ -62,13 +62,13 @@ def is_less_than_or_equal_to(value)
end
def odd
- odd_number_matcher = NumericalityMatchers::OddEvenNumberMatcher.new(@attribute, :odd => true)
+ odd_number_matcher = NumericalityMatchers::OddEvenNumberMatcher.new(@attribute, odd: true)
add_submatcher(odd_number_matcher)
self
end
def even
- even_number_matcher = NumericalityMatchers::OddEvenNumberMatcher.new(@attribute, :even => true)
+ even_number_matcher = NumericalityMatchers::OddEvenNumberMatcher.new(@attribute, even: true)
add_submatcher(even_number_matcher)
self
end
@@ -284,7 +284,7 @@ def validate_correct?
if option_verifier.correct_for_boolean?(:validate, options[:validate])
true
else
- @missing = "#{name} should have :validate => #{options[:validate]}"
+ @missing = "#{name} should have validate: #{options[:validate]}"
false
end
end
@@ -293,7 +293,7 @@ def touch_correct?
if option_verifier.correct_for_boolean?(:touch, options[:touch])
true
else
- @missing = "#{name} should have :touch => #{options[:touch]}"
+ @missing = "#{name} should have touch: #{options[:touch]}"
false
end
end
@@ -13,7 +13,7 @@ module ActiveRecord # :nodoc:
# it { should_not have_db_column(:admin).of_type(:boolean) }
# it { should have_db_column(:salary).
# of_type(:decimal).
- # with_options(:precision => 10, :scale => 2) }
+ # with_options(precision: 10, scale: 2) }
#
def have_db_column(column)
HaveDbColumnMatcher.new(column)
@@ -28,7 +28,7 @@ def controller_redirecting_to(url)
context 'a controller that does not redirect' do
it 'rejects redirecting to a url' do
- controller = build_response { render :text => 'hello' }
+ controller = build_response { render text: 'hello' }
controller.should_not redirect_to('/some/url')
end
@@ -21,57 +21,57 @@
end
def controller_with_show
- build_response(:action => 'show') { render }
+ build_response(action: 'show') { render }
end
end
context 'a controller that renders a partial' do
it 'accepts rendering that partial' do
controller_with_customer_partial.
- should render_template(:partial => '_customer')
+ should render_template(partial: '_customer')
end
it 'rejects rendering a different template' do
controller_with_customer_partial.
- should_not render_template(:partial => '_client')
+ should_not render_template(partial: '_client')
end
it 'accepts rendering that template in the given context' do
controller_with_customer_partial.
- should render_template(:partial => '_customer').in_context(self)
+ should render_template(partial: '_customer').in_context(self)
end
it 'rejects rendering a different template in the given context' do
controller_with_customer_partial.
- should_not render_template(:partial => '_client').in_context(self)
+ should_not render_template(partial: '_client').in_context(self)
end
def controller_with_customer_partial
- build_response(:partial => '_customer') { render :partial => 'customer' }
+ build_response(partial: '_customer') { render partial: 'customer' }
end
end
context 'a controller that does not render partials' do
it 'accepts not rendering a partial' do
- controller = build_response(:action => 'show') { render }
+ controller = build_response(action: 'show') { render }
- controller.should render_template(:partial => false)
+ controller.should render_template(partial: false)
end
end
context 'a controller that renders a partial several times' do
it 'accepts rendering that partial twice' do
- controller = build_response(:partial => '_customer') do
- render :partial => 'customer', :collection => [1,2]
+ controller = build_response(partial: '_customer') do
+ render partial: 'customer', collection: [1,2]
end
- controller.should render_template(:partial => '_customer', :count => 2)
+ controller.should render_template(partial: '_customer', count: 2)
end
end
context 'a controller that does not render a template' do
it 'rejects rendering a template' do
- build_response { render :nothing => true }.
+ build_response { render nothing: true }.
should_not render_template(:show)
end
end
@@ -18,22 +18,22 @@
def controller_with_wide_layout
create_view('layouts/wide.html.erb', 'some content, <%= yield %>')
- build_response { render :layout => 'wide' }
+ build_response { render layout: 'wide' }
end
end
context 'a controller that renders without a layout' do
it 'rejects rendering with a layout' do
- controller_without_layout = build_response { render :layout => false }
+ controller_without_layout = build_response { render layout: false }
controller_without_layout.should_not render_with_layout
end
end
context 'a controller that renders a partial' do
it 'rejects rendering with a layout' do
- controller_with_partial = build_response { render :partial => 'partial' }
+ controller_with_partial = build_response { render partial: 'partial' }
controller_with_partial.should_not render_with_layout
end
@@ -57,7 +57,7 @@ def layouts_ivar
end
def controller_without_layout
- build_response { render :layout => false }
+ build_response { render layout: false }
end
end
end
@@ -1,8 +1,8 @@
require 'spec_helper'
describe Shoulda::Matchers::ActionController::RespondWithMatcher do
- statuses = { :success => 200, :redirect => 301, :missing => 404, :error => 500,
- :not_implemented => 501 }
+ statuses = { success: 200, redirect: 301, missing: 404, error: 500,
+ not_implemented: 501 }
statuses.each do |human_name, numeric_code|
context "a controller responding with #{human_name}" do
@@ -25,7 +25,7 @@
def controller_with_status(status)
build_response do
- render :text => 'text', :status => status
+ render text: 'text', status: status
end
end
end
Oops, something went wrong.

0 comments on commit fcbb5c4

Please sign in to comment.