Skip to content

Commit 7870656

Browse files
hmtanbirJonRowe
authored andcommitted
Switch from hash rocket style to 1.9 style hash keys (#2224)
1 parent 4b75a0d commit 7870656

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+203
-207
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ Metrics/MethodLength:
1818
Style/EachWithObject:
1919
Enabled: false
2020

21-
# ruby 1.8.7 only had support for hash rockets
22-
Style/HashSyntax:
23-
EnforcedStyle: hash_rockets # default: ruby19
24-
2521
# the new lambda syntax was not supported in ruby 1.8.7
2622
Style/Lambda:
2723
Enabled: false

Capybara.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,5 @@ behavior and accepting the risks associated with doing so:
7373

7474
# not recommended!
7575
RSpec.configure do |c|
76-
c.include Capybara::DSL, :file_path => "spec/requests"
76+
c.include Capybara::DSL, file_path: "spec/requests"
7777
end

Changelog.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,10 @@ Enhancements:
344344
* Improve controller and routing spec calls to `routes` by using `yield`
345345
instead of `call`. (Anton Davydov, #1308)
346346
* Add support for `ActiveJob` specs as standard `RSpec::Rails::RailsExampleGoup`s
347-
via both `:type => :job` and inferring type from spec directory `spec/jobs`.
347+
via both `type: :job` and inferring type from spec directory `spec/jobs`.
348348
(Gabe Martin-Dempesy, #1361)
349349
* Include `RSpec::Rails::FixtureSupport` into example groups using metadata
350-
`:use_fixtures => true`. (Aaron Kromer, #1372)
350+
`use_fixtures: true`. (Aaron Kromer, #1372)
351351
* Include `rspec:request` generator for generating request specs; this is an
352352
alias of `rspec:integration` (Aaron Kromer, #1378)
353353
* Update `rails_helper` generator with a default check to abort the spec run
@@ -488,7 +488,7 @@ Enhancements:
488488
Bug Fixes:
489489

490490
* Fix an inconsistency in the generated scaffold specs for a controller. (Andy Waite)
491-
* Ensure `config.before(:all, :type => <type>)` hooks run before groups
491+
* Ensure `config.before(:all, type: <type>)` hooks run before groups
492492
of the given type, even when the type is inferred by the file
493493
location. (Jon Rowe, Myron Marston)
494494
* Switch to parsing params with `Rack::Utils::parse_nested_query` to match Rails.
@@ -938,7 +938,7 @@ This release is compatible with rails-3.1.0.rc1, but not rails-3.1.0.beta1
938938
* Enhancements
939939
* include ApplicationHelper in helper object in helper specs
940940
* include request spec extensions in files in spec/integration
941-
* include controller spec extensions in groups that use :type => :controller
941+
* include controller spec extensions in groups that use type: :controller
942942
* same for :model, :view, :helper, :mailer, :request, :routing
943943

944944
* Bug fixes

Gemfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ gemspec
77
rspec_dependencies_gemfile = File.expand_path("../Gemfile-rspec-dependencies", __FILE__)
88
eval_gemfile rspec_dependencies_gemfile
99

10-
gem 'yard', '~> 0.8.7', :require => false
10+
gem 'yard', '~> 0.8.7', require: false
1111

1212
### deps for rdoc.info
1313
group :documentation do
14-
gem 'redcarpet', '~> 3.4.0', platforms: [:ruby]
1514
gem 'github-markup', '~> 3.0.3'
15+
gem 'redcarpet', '~> 3.4.0', platforms: [:ruby]
1616
gem 'relish', '~> 0.7.1'
1717
end
1818

@@ -36,8 +36,8 @@ else
3636
end
3737

3838
if MAJOR >= 6
39+
gem 'selenium-webdriver', '~> 3.5', require: false
3940
gem 'sqlite3', '~> 1.4', platforms: [:ruby]
40-
gem 'selenium-webdriver', '~> 3.5', :require => false
4141
else
4242
gem 'sqlite3', '~> 1.3.6', platforms: [:ruby]
4343
end
@@ -57,7 +57,7 @@ if RUBY_VERSION < '2.4.0'
5757
gem 'minitest', '< 5.12.0'
5858
end
5959

60-
gem 'capybara', '~> 2.13', :require => false
60+
gem 'capybara', '~> 2.13', require: false
6161

6262
if MAJOR < 6
6363
gem 'nokogiri', '1.8.5'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Use **[`rspec-rails` 1.x][]** for Rails 2.x.
3535
# (requires master-branch versions of all related RSpec libraries)
3636
group :development, :test do
3737
%w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib|
38-
gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => 'master'
38+
gem lib, git: "https://github.com/rspec/#{lib}.git", branch: 'master'
3939
end
4040
end
4141
```

features/matchers/have_broadcasted_matcher.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Feature: have_broadcasted matcher
104104
"""ruby
105105
require "rails_helper"
106106
107-
RSpec.describe ChatChannel, :type => :channel do
107+
RSpec.describe ChatChannel, type: :channel do
108108
it "successfully subscribes" do
109109
user = User.new(42)
110110

features/matchers/have_enqueued_mail_matcher.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Feature: have_enqueued_mail matcher
3333
it "matches with enqueued mailer" do
3434
ActiveJob::Base.queue_adapter = :test
3535
expect {
36-
NotificationsMailer.signup.deliver_later(:wait_until => Date.tomorrow.noon)
36+
NotificationsMailer.signup.deliver_later(wait_until: Date.tomorrow.noon)
3737
}.to have_enqueued_mail.at(Date.tomorrow.noon)
3838
end
3939
end

features/step_definitions/additional_cli_steps.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
begin
22
require "active_job"
3-
rescue LoadError # rubocop:disable Lint/HandleExceptions
3+
rescue LoadError # rubocop:disable Lint/SuppressedException
44
end
55
begin
66
require "action_cable"
7-
rescue LoadError # rubocop:disable Lint/HandleExceptions
7+
rescue LoadError # rubocop:disable Lint/SuppressedException
88
end
99

1010
require "rails/version"

lib/generators/rspec/controller/controller_generator.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ module Rspec
44
module Generators
55
# @private
66
class ControllerGenerator < Base
7-
argument :actions, :type => :array, :default => [], :banner => "action action"
7+
argument :actions, type: :array, default: [], banner: "action action"
88

9-
class_option :template_engine, :desc => "Template engine to generate view files"
10-
class_option :controller_specs, :type => :boolean, :default => true, :desc => "Generate controller specs"
11-
class_option :view_specs, :type => :boolean, :default => true, :desc => "Generate view specs"
12-
class_option :routing_specs, :type => :boolean, :default => false, :desc => "Generate routing specs"
9+
class_option :template_engine, desc: "Template engine to generate view files"
10+
class_option :controller_specs, type: :boolean, default: true, desc: "Generate controller specs"
11+
class_option :view_specs, type: :boolean, default: true, desc: "Generate view specs"
12+
class_option :routing_specs, type: :boolean, default: false, desc: "Generate routing specs"
1313

1414
def generate_controller_spec
1515
return unless options[:controller_specs]

lib/generators/rspec/controller/templates/routing_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
describe 'routing' do
66
<% for action in actions -%>
77
it 'routes to #<%= action %>' do
8-
expect(:get => "/<%= class_name.underscore %>/<%= action %>").to route_to("<%= class_name.underscore %>#<%= action %>")
8+
expect(get: "/<%= class_name.underscore %>/<%= action %>").to route_to("<%= class_name.underscore %>#<%= action %>")
99
end
1010
<% end -%>
1111
end

lib/generators/rspec/feature/feature_generator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module Rspec
44
module Generators
55
# @private
66
class FeatureGenerator < Base
7-
class_option :feature_specs, :type => :boolean, :default => true, :desc => "Generate feature specs"
8-
class_option :singularize, :type => :boolean, :default => false, :desc => "Singularize the generated feature"
7+
class_option :feature_specs, type: :boolean, default: true, desc: "Generate feature specs"
8+
class_option :singularize, type: :boolean, default: false, desc: "Singularize the generated feature"
99

1010
def generate_feature_spec
1111
return unless options[:feature_specs]

lib/generators/rspec/generators/generator_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Rspec
44
module Generators
55
# @private
66
class GeneratorsGenerator < Base
7-
class_option :generator_specs, :type => :boolean, :default => false, :desc => "Generate generator specs"
7+
class_option :generator_specs, type: :boolean, default: false, desc: "Generate generator specs"
88

99
def generate_generator_spec
1010
return unless options[:generator_specs]

lib/generators/rspec/helper/helper_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Rspec
44
module Generators
55
# @private
66
class HelperGenerator < Base
7-
class_option :helper_specs, :type => :boolean, :default => true
7+
class_option :helper_specs, type: :boolean, default: true
88

99
def generate_helper_spec
1010
return unless options[:helper_specs]

lib/generators/rspec/install/install_generator.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def copy_rails_files
3232

3333
def generate_rspec_init(tmpdir)
3434
initializer = ::RSpec::Core::ProjectInitializer.new(
35-
:destination => tmpdir,
36-
:report_stream => StringIO.new
35+
destination: tmpdir,
36+
report_stream: StringIO.new
3737
)
3838
initializer.run
3939

@@ -47,7 +47,7 @@ def replace_generator_command(spec_helper_path)
4747
gsub_file spec_helper_path,
4848
'rspec --init',
4949
'rails generate rspec:install',
50-
:verbose => false
50+
verbose: false
5151
end
5252

5353
def remove_warnings_configuration(spec_helper_path)
@@ -56,7 +56,7 @@ def remove_warnings_configuration(spec_helper_path)
5656
gsub_file spec_helper_path,
5757
/#{empty_line}(#{comment_line})+\s+config\.warnings = true\n/,
5858
'',
59-
:verbose => false
59+
verbose: false
6060
end
6161
end
6262
end

lib/generators/rspec/install/templates/spec/rails_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
# You can disable this behaviour by removing the line below, and instead
6464
# explicitly tag your specs with their type, e.g.:
6565
#
66-
# RSpec.describe UsersController, :type => :controller do
66+
# RSpec.describe UsersController, type: :controller do
6767
# # ...
6868
# end
6969
#

lib/generators/rspec/integration/integration_generator.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ class IntegrationGenerator < Base
77
# Add a deprecation for this class, before rspec-rails 4, to use the
88
# `RequestGenerator` instead
99
class_option :request_specs,
10-
:type => :boolean,
11-
:default => true,
12-
:desc => "Generate request specs"
10+
type: :boolean,
11+
default: true,
12+
desc: "Generate request specs"
1313

1414
def generate_request_spec
1515
return unless options[:request_specs]

lib/generators/rspec/mailer/mailer_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Rspec
55
module Generators
66
# @private
77
class MailerGenerator < Base
8-
argument :actions, :type => :array, :default => [], :banner => "method method"
8+
argument :actions, type: :array, default: [], banner: "method method"
99

1010
def generate_mailer_spec
1111
template "mailer_spec.rb", File.join('spec/mailers', class_path, "#{file_name}_spec.rb")

lib/generators/rspec/model/model_generator.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ module Generators
55
# @private
66
class ModelGenerator < Base
77
argument :attributes,
8-
:type => :array,
9-
:default => [],
10-
:banner => "field:type field:type"
11-
class_option :fixture, :type => :boolean
8+
type: :array,
9+
default: [],
10+
banner: "field:type field:type"
11+
class_option :fixture, type: :boolean
1212

1313
def create_model_spec
1414
template_file = File.join(

lib/generators/rspec/scaffold/scaffold_generator.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ module Generators
77
class ScaffoldGenerator < Base
88
include ::Rails::Generators::ResourceHelpers
99
source_paths << File.expand_path('../helper/templates', __dir__)
10-
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
10+
argument :attributes, type: :array, default: [], banner: "field:type field:type"
1111

12-
class_option :orm, :desc => "ORM used to generate the controller"
13-
class_option :template_engine, :desc => "Template engine to generate view files"
14-
class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller"
15-
class_option :api, :type => :boolean, :desc => "Skip specs unnecessary for API-only apps"
12+
class_option :orm, desc: "ORM used to generate the controller"
13+
class_option :template_engine, desc: "Template engine to generate view files"
14+
class_option :singleton, type: :boolean, desc: "Supply to create a singleton controller"
15+
class_option :api, type: :boolean, desc: "Skip specs unnecessary for API-only apps"
1616

17-
class_option :controller_specs, :type => :boolean, :default => true, :desc => "Generate controller specs"
18-
class_option :view_specs, :type => :boolean, :default => true, :desc => "Generate view specs"
19-
class_option :helper_specs, :type => :boolean, :default => true, :desc => "Generate helper specs"
20-
class_option :routing_specs, :type => :boolean, :default => true, :desc => "Generate routing specs"
17+
class_option :controller_specs, type: :boolean, default: true, desc: "Generate controller specs"
18+
class_option :view_specs, type: :boolean, default: true, desc: "Generate view specs"
19+
class_option :helper_specs, type: :boolean, default: true, desc: "Generate helper specs"
20+
class_option :routing_specs, type: :boolean, default: true, desc: "Generate routing specs"
2121

2222
def initialize(*args, &blk)
2323
@generator_args = args.first
@@ -60,7 +60,7 @@ def generate_routing_spec
6060
template 'routing_spec.rb', template_file
6161
end
6262

63-
hook_for :integration_tool, :as => :integration
63+
hook_for :integration_tool, as: :integration
6464

6565
protected
6666

lib/generators/rspec/scaffold/templates/api_controller_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
it "returns a success response" do
6161
<%= file_name %> = <%= class_name %>.create! valid_attributes
6262
<% if RUBY_VERSION < '1.9.3' -%>
63-
get :show, {:id => <%= file_name %>.to_param}, valid_session
63+
get :show, {id: <%= file_name %>.to_param}, valid_session
6464
<% else -%>
6565
get :show, params: {id: <%= file_name %>.to_param}, session: valid_session
6666
<% end -%>
@@ -73,7 +73,7 @@
7373
it "creates a new <%= class_name %>" do
7474
expect {
7575
<% if RUBY_VERSION < '1.9.3' -%>
76-
post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
76+
post :create, {<%= ns_file_name %>: valid_attributes}, valid_session
7777
<% else -%>
7878
post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
7979
<% end -%>
@@ -82,7 +82,7 @@
8282
8383
it "renders a JSON response with the new <%= ns_file_name %>" do
8484
<% if RUBY_VERSION < '1.9.3' -%>
85-
post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
85+
post :create, {<%= ns_file_name %>: valid_attributes}, valid_session
8686
<% else %>
8787
post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
8888
<% end -%>
@@ -95,7 +95,7 @@
9595
context "with invalid params" do
9696
it "renders a JSON response with errors for the new <%= ns_file_name %>" do
9797
<% if RUBY_VERSION < '1.9.3' -%>
98-
post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session
98+
post :create, {<%= ns_file_name %>: invalid_attributes}, valid_session
9999
<% else %>
100100
post :create, params: {<%= ns_file_name %>: invalid_attributes}, session: valid_session
101101
<% end -%>
@@ -114,7 +114,7 @@
114114
it "updates the requested <%= ns_file_name %>" do
115115
<%= file_name %> = <%= class_name %>.create! valid_attributes
116116
<% if RUBY_VERSION < '1.9.3' -%>
117-
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => new_attributes}, valid_session
117+
put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, valid_session
118118
<% else -%>
119119
put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, session: valid_session
120120
<% end -%>
@@ -125,7 +125,7 @@
125125
it "renders a JSON response with the <%= ns_file_name %>" do
126126
<%= file_name %> = <%= class_name %>.create! valid_attributes
127127
<% if RUBY_VERSION < '1.9.3' -%>
128-
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
128+
put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, valid_session
129129
<% else %>
130130
put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, session: valid_session
131131
<% end -%>
@@ -138,7 +138,7 @@
138138
it "renders a JSON response with errors for the <%= ns_file_name %>" do
139139
<%= file_name %> = <%= class_name %>.create! valid_attributes
140140
<% if RUBY_VERSION < '1.9.3' -%>
141-
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
141+
put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, valid_session
142142
<% else %>
143143
put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, session: valid_session
144144
<% end -%>
@@ -153,7 +153,7 @@
153153
<%= file_name %> = <%= class_name %>.create! valid_attributes
154154
expect {
155155
<% if RUBY_VERSION < '1.9.3' -%>
156-
delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
156+
delete :destroy, {id: <%= file_name %>.to_param}, valid_session
157157
<% else -%>
158158
delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session
159159
<% end -%>

0 commit comments

Comments
 (0)