diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d4dffc2e57..6ebda43474 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -20,7 +20,7 @@ Style/EachWithObject: # ruby 1.8.7 only had support for hash rockets Style/HashSyntax: - EnforcedStyle: hash_rockets # default: ruby19 + EnforcedStyle: ruby19 # default: ruby19 # the new lambda syntax was not supported in ruby 1.8.7 Style/Lambda: diff --git a/README.md b/README.md index 3dc5247470..72d2c81920 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Use **[`rspec-rails` 1.x][]** for Rails 2.x. # (requires master-branch versions of all related RSpec libraries) group :development, :test do %w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib| - gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => 'master' + gem lib, git: "https://github.com/rspec/#{lib}.git", branch: 'master' end end ``` diff --git a/features/step_definitions/additional_cli_steps.rb b/features/step_definitions/additional_cli_steps.rb index 622ddbec33..e4d7cd07ee 100644 --- a/features/step_definitions/additional_cli_steps.rb +++ b/features/step_definitions/additional_cli_steps.rb @@ -1,10 +1,10 @@ begin require "active_job" -rescue LoadError # rubocop:disable Lint/HandleExceptions +rescue LoadError # rubocop:disable Lint/SuppressedException end begin require "action_cable" -rescue LoadError # rubocop:disable Lint/HandleExceptions +rescue LoadError # rubocop:disable Lint/SuppressedException end require "rails/version" diff --git a/lib/generators/rspec/controller/controller_generator.rb b/lib/generators/rspec/controller/controller_generator.rb index dc3c23d37b..a82a2cfbd1 100644 --- a/lib/generators/rspec/controller/controller_generator.rb +++ b/lib/generators/rspec/controller/controller_generator.rb @@ -4,12 +4,12 @@ module Rspec module Generators # @private class ControllerGenerator < Base - argument :actions, :type => :array, :default => [], :banner => "action action" + argument :actions, type: :array, default: [], banner: "action action" - class_option :template_engine, :desc => "Template engine to generate view files" - class_option :controller_specs, :type => :boolean, :default => true, :desc => "Generate controller specs" - class_option :view_specs, :type => :boolean, :default => true, :desc => "Generate view specs" - class_option :routing_specs, :type => :boolean, :default => false, :desc => "Generate routing specs" + class_option :template_engine, desc: "Template engine to generate view files" + class_option :controller_specs, type: :boolean, default: true, desc: "Generate controller specs" + class_option :view_specs, type: :boolean, default: true, desc: "Generate view specs" + class_option :routing_specs, type: :boolean, default: false, desc: "Generate routing specs" def generate_controller_spec return unless options[:controller_specs] diff --git a/lib/generators/rspec/controller/templates/routing_spec.rb b/lib/generators/rspec/controller/templates/routing_spec.rb index 08550dd20a..2fe851d0e2 100644 --- a/lib/generators/rspec/controller/templates/routing_spec.rb +++ b/lib/generators/rspec/controller/templates/routing_spec.rb @@ -5,7 +5,7 @@ describe 'routing' do <% for action in actions -%> it 'routes to #<%= action %>' do - expect(:get => "/<%= class_name.underscore %>/<%= action %>").to route_to("<%= class_name.underscore %>#<%= action %>") + expect(get: "/<%= class_name.underscore %>/<%= action %>").to route_to("<%= class_name.underscore %>#<%= action %>") end <% end -%> end diff --git a/lib/generators/rspec/feature/feature_generator.rb b/lib/generators/rspec/feature/feature_generator.rb index 66c469bebc..5b9bfc4675 100644 --- a/lib/generators/rspec/feature/feature_generator.rb +++ b/lib/generators/rspec/feature/feature_generator.rb @@ -4,8 +4,8 @@ module Rspec module Generators # @private class FeatureGenerator < Base - class_option :feature_specs, :type => :boolean, :default => true, :desc => "Generate feature specs" - class_option :singularize, :type => :boolean, :default => false, :desc => "Singularize the generated feature" + class_option :feature_specs, type: :boolean, default: true, desc: "Generate feature specs" + class_option :singularize, type: :boolean, default: false, desc: "Singularize the generated feature" def generate_feature_spec return unless options[:feature_specs] diff --git a/lib/generators/rspec/generators/generator_generator.rb b/lib/generators/rspec/generators/generator_generator.rb index 7ce9806c41..0b55fccc45 100644 --- a/lib/generators/rspec/generators/generator_generator.rb +++ b/lib/generators/rspec/generators/generator_generator.rb @@ -4,7 +4,7 @@ module Rspec module Generators # @private class GeneratorsGenerator < Base - class_option :generator_specs, :type => :boolean, :default => false, :desc => "Generate generator specs" + class_option :generator_specs, type: :boolean, default: false, desc: "Generate generator specs" def generate_generator_spec return unless options[:generator_specs] diff --git a/lib/generators/rspec/helper/helper_generator.rb b/lib/generators/rspec/helper/helper_generator.rb index 466cb51c08..a035f8e4a7 100644 --- a/lib/generators/rspec/helper/helper_generator.rb +++ b/lib/generators/rspec/helper/helper_generator.rb @@ -4,7 +4,7 @@ module Rspec module Generators # @private class HelperGenerator < Base - class_option :helper_specs, :type => :boolean, :default => true + class_option :helper_specs, type: :boolean, default: true def generate_helper_spec return unless options[:helper_specs] diff --git a/lib/generators/rspec/install/install_generator.rb b/lib/generators/rspec/install/install_generator.rb index a8d8612e7e..8b832089d3 100644 --- a/lib/generators/rspec/install/install_generator.rb +++ b/lib/generators/rspec/install/install_generator.rb @@ -32,8 +32,8 @@ def copy_rails_files def generate_rspec_init(tmpdir) initializer = ::RSpec::Core::ProjectInitializer.new( - :destination => tmpdir, - :report_stream => StringIO.new + destination: tmpdir, + report_stream: StringIO.new ) initializer.run @@ -47,7 +47,7 @@ def replace_generator_command(spec_helper_path) gsub_file spec_helper_path, 'rspec --init', 'rails generate rspec:install', - :verbose => false + verbose: false end def remove_warnings_configuration(spec_helper_path) @@ -56,7 +56,7 @@ def remove_warnings_configuration(spec_helper_path) gsub_file spec_helper_path, /#{empty_line}(#{comment_line})+\s+config\.warnings = true\n/, '', - :verbose => false + verbose: false end end end diff --git a/lib/generators/rspec/install/templates/spec/rails_helper.rb b/lib/generators/rspec/install/templates/spec/rails_helper.rb index 03672af7f6..71e7104d57 100644 --- a/lib/generators/rspec/install/templates/spec/rails_helper.rb +++ b/lib/generators/rspec/install/templates/spec/rails_helper.rb @@ -63,7 +63,7 @@ # You can disable this behaviour by removing the line below, and instead # explicitly tag your specs with their type, e.g.: # - # RSpec.describe UsersController, :type => :controller do + # RSpec.describe UsersController, type: :controller do # # ... # end # diff --git a/lib/generators/rspec/integration/integration_generator.rb b/lib/generators/rspec/integration/integration_generator.rb index b48923c715..f820b017f9 100644 --- a/lib/generators/rspec/integration/integration_generator.rb +++ b/lib/generators/rspec/integration/integration_generator.rb @@ -7,9 +7,9 @@ class IntegrationGenerator < Base # Add a deprecation for this class, before rspec-rails 4, to use the # `RequestGenerator` instead class_option :request_specs, - :type => :boolean, - :default => true, - :desc => "Generate request specs" + type: :boolean, + default: true, + desc: "Generate request specs" def generate_request_spec return unless options[:request_specs] diff --git a/lib/generators/rspec/mailer/mailer_generator.rb b/lib/generators/rspec/mailer/mailer_generator.rb index 768dfe8d45..0030dbffe4 100644 --- a/lib/generators/rspec/mailer/mailer_generator.rb +++ b/lib/generators/rspec/mailer/mailer_generator.rb @@ -5,7 +5,7 @@ module Rspec module Generators # @private class MailerGenerator < Base - argument :actions, :type => :array, :default => [], :banner => "method method" + argument :actions, type: :array, default: [], banner: "method method" def generate_mailer_spec template "mailer_spec.rb", File.join('spec/mailers', class_path, "#{file_name}_spec.rb") diff --git a/lib/generators/rspec/model/model_generator.rb b/lib/generators/rspec/model/model_generator.rb index fcbaaecb52..6ab0ffb666 100644 --- a/lib/generators/rspec/model/model_generator.rb +++ b/lib/generators/rspec/model/model_generator.rb @@ -5,10 +5,10 @@ module Generators # @private class ModelGenerator < Base argument :attributes, - :type => :array, - :default => [], - :banner => "field:type field:type" - class_option :fixture, :type => :boolean + type: :array, + default: [], + banner: "field:type field:type" + class_option :fixture, type: :boolean def create_model_spec template_file = File.join( diff --git a/lib/generators/rspec/scaffold/scaffold_generator.rb b/lib/generators/rspec/scaffold/scaffold_generator.rb index 67cf0c85a7..3bb6ec91d0 100644 --- a/lib/generators/rspec/scaffold/scaffold_generator.rb +++ b/lib/generators/rspec/scaffold/scaffold_generator.rb @@ -7,17 +7,17 @@ module Generators class ScaffoldGenerator < Base include ::Rails::Generators::ResourceHelpers source_paths << File.expand_path('../helper/templates', __dir__) - argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" + argument :attributes, type: :array, default: [], banner: "field:type field:type" - class_option :orm, :desc => "ORM used to generate the controller" - class_option :template_engine, :desc => "Template engine to generate view files" - class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller" - class_option :api, :type => :boolean, :desc => "Skip specs unnecessary for API-only apps" + class_option :orm, desc: "ORM used to generate the controller" + class_option :template_engine, desc: "Template engine to generate view files" + class_option :singleton, type: :boolean, desc: "Supply to create a singleton controller" + class_option :api, type: :boolean, desc: "Skip specs unnecessary for API-only apps" - class_option :controller_specs, :type => :boolean, :default => true, :desc => "Generate controller specs" - class_option :view_specs, :type => :boolean, :default => true, :desc => "Generate view specs" - class_option :helper_specs, :type => :boolean, :default => true, :desc => "Generate helper specs" - class_option :routing_specs, :type => :boolean, :default => true, :desc => "Generate routing specs" + class_option :controller_specs, type: :boolean, default: true, desc: "Generate controller specs" + class_option :view_specs, type: :boolean, default: true, desc: "Generate view specs" + class_option :helper_specs, type: :boolean, default: true, desc: "Generate helper specs" + class_option :routing_specs, type: :boolean, default: true, desc: "Generate routing specs" def initialize(*args, &blk) @generator_args = args.first @@ -60,7 +60,7 @@ def generate_routing_spec template 'routing_spec.rb', template_file end - hook_for :integration_tool, :as => :integration + hook_for :integration_tool, as: :integration protected diff --git a/lib/generators/rspec/scaffold/templates/api_controller_spec.rb b/lib/generators/rspec/scaffold/templates/api_controller_spec.rb index 39d055b674..1fc24e8402 100644 --- a/lib/generators/rspec/scaffold/templates/api_controller_spec.rb +++ b/lib/generators/rspec/scaffold/templates/api_controller_spec.rb @@ -60,7 +60,7 @@ it "returns a success response" do <%= file_name %> = <%= class_name %>.create! valid_attributes <% if RUBY_VERSION < '1.9.3' -%> - get :show, {:id => <%= file_name %>.to_param}, valid_session + get :show, {id: <%= file_name %>.to_param}, valid_session <% else -%> get :show, params: {id: <%= file_name %>.to_param}, session: valid_session <% end -%> @@ -73,7 +73,7 @@ it "creates a new <%= class_name %>" do expect { <% if RUBY_VERSION < '1.9.3' -%> - post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session + post :create, {<%= ns_file_name %>: valid_attributes}, valid_session <% else -%> post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session <% end -%> @@ -82,7 +82,7 @@ it "renders a JSON response with the new <%= ns_file_name %>" do <% if RUBY_VERSION < '1.9.3' -%> - post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session + post :create, {<%= ns_file_name %>: valid_attributes}, valid_session <% else %> post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session <% end -%> @@ -95,7 +95,7 @@ context "with invalid params" do it "renders a JSON response with errors for the new <%= ns_file_name %>" do <% if RUBY_VERSION < '1.9.3' -%> - post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session + post :create, {<%= ns_file_name %>: invalid_attributes}, valid_session <% else %> post :create, params: {<%= ns_file_name %>: invalid_attributes}, session: valid_session <% end -%> @@ -114,7 +114,7 @@ it "updates the requested <%= ns_file_name %>" do <%= file_name %> = <%= class_name %>.create! valid_attributes <% if RUBY_VERSION < '1.9.3' -%> - put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => new_attributes}, valid_session + put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, valid_session <% else -%> put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, session: valid_session <% end -%> @@ -125,7 +125,7 @@ it "renders a JSON response with the <%= ns_file_name %>" do <%= file_name %> = <%= class_name %>.create! valid_attributes <% if RUBY_VERSION < '1.9.3' -%> - put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session + put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, valid_session <% else %> put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, session: valid_session <% end -%> @@ -138,7 +138,7 @@ it "renders a JSON response with errors for the <%= ns_file_name %>" do <%= file_name %> = <%= class_name %>.create! valid_attributes <% if RUBY_VERSION < '1.9.3' -%> - put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session + put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, valid_session <% else %> put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, session: valid_session <% end -%> @@ -153,7 +153,7 @@ <%= file_name %> = <%= class_name %>.create! valid_attributes expect { <% if RUBY_VERSION < '1.9.3' -%> - delete :destroy, {:id => <%= file_name %>.to_param}, valid_session + delete :destroy, {id: <%= file_name %>.to_param}, valid_session <% else -%> delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session <% end -%> diff --git a/lib/generators/rspec/scaffold/templates/controller_spec.rb b/lib/generators/rspec/scaffold/templates/controller_spec.rb index 7f5799a199..b2a80a38e0 100644 --- a/lib/generators/rspec/scaffold/templates/controller_spec.rb +++ b/lib/generators/rspec/scaffold/templates/controller_spec.rb @@ -60,7 +60,7 @@ it "returns a success response" do <%= file_name %> = <%= class_name %>.create! valid_attributes <% if Rails::VERSION::STRING < '5.0' -%> - get :show, {:id => <%= file_name %>.to_param}, valid_session + get :show, {id: <%= file_name %>.to_param}, valid_session <% else -%> get :show, params: {id: <%= file_name %>.to_param}, session: valid_session <% end -%> @@ -83,7 +83,7 @@ it "returns a success response" do <%= file_name %> = <%= class_name %>.create! valid_attributes <% if Rails::VERSION::STRING < '5.0' -%> - get :edit, {:id => <%= file_name %>.to_param}, valid_session + get :edit, {id: <%= file_name %>.to_param}, valid_session <% else -%> get :edit, params: {id: <%= file_name %>.to_param}, session: valid_session <% end -%> @@ -96,7 +96,7 @@ it "creates a new <%= class_name %>" do expect { <% if Rails::VERSION::STRING < '5.0' -%> - post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session + post :create, {<%= ns_file_name %>: valid_attributes}, valid_session <% else -%> post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session <% end -%> @@ -105,7 +105,7 @@ it "redirects to the created <%= ns_file_name %>" do <% if Rails::VERSION::STRING < '5.0' -%> - post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session + post :create, {<%= ns_file_name %>: valid_attributes}, valid_session <% else -%> post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session <% end -%> @@ -116,7 +116,7 @@ context "with invalid params" do it "returns a success response (i.e. to display the 'new' template)" do <% if Rails::VERSION::STRING < '5.0' -%> - post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session + post :create, {<%= ns_file_name %>: invalid_attributes}, valid_session <% else -%> post :create, params: {<%= ns_file_name %>: invalid_attributes}, session: valid_session <% end -%> @@ -134,7 +134,7 @@ it "updates the requested <%= ns_file_name %>" do <%= file_name %> = <%= class_name %>.create! valid_attributes <% if Rails::VERSION::STRING < '5.0' -%> - put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => new_attributes}, valid_session + put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, valid_session <% else -%> put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, session: valid_session <% end -%> @@ -145,7 +145,7 @@ it "redirects to the <%= ns_file_name %>" do <%= file_name %> = <%= class_name %>.create! valid_attributes <% if Rails::VERSION::STRING < '5.0' -%> - put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session + put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, valid_session <% else -%> put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, session: valid_session <% end -%> @@ -157,7 +157,7 @@ it "returns a success response (i.e. to display the 'edit' template)" do <%= file_name %> = <%= class_name %>.create! valid_attributes <% if Rails::VERSION::STRING < '5.0' -%> - put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session + put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, valid_session <% else -%> put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, session: valid_session <% end -%> @@ -171,7 +171,7 @@ <%= file_name %> = <%= class_name %>.create! valid_attributes expect { <% if Rails::VERSION::STRING < '5.0' -%> - delete :destroy, {:id => <%= file_name %>.to_param}, valid_session + delete :destroy, {id: <%= file_name %>.to_param}, valid_session <% else -%> delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session <% end -%> @@ -181,7 +181,7 @@ it "redirects to the <%= table_name %> list" do <%= file_name %> = <%= class_name %>.create! valid_attributes <% if Rails::VERSION::STRING < '5.0' -%> - delete :destroy, {:id => <%= file_name %>.to_param}, valid_session + delete :destroy, {id: <%= file_name %>.to_param}, valid_session <% else -%> delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session <% end -%> diff --git a/lib/generators/rspec/scaffold/templates/edit_spec.rb b/lib/generators/rspec/scaffold/templates/edit_spec.rb index 3774477f57..072c2f0a66 100644 --- a/lib/generators/rspec/scaffold/templates/edit_spec.rb +++ b/lib/generators/rspec/scaffold/templates/edit_spec.rb @@ -5,7 +5,7 @@ before(:each) do @<%= ns_file_name %> = assign(:<%= ns_file_name %>, <%= class_name %>.create!(<%= '))' if output_attributes.empty? %> <% output_attributes.each_with_index do |attribute, attribute_index| -%> - :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%> + <%= attribute.name %>: <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%> <% end -%> <%= output_attributes.empty? ? "" : " ))\n" -%> end diff --git a/lib/generators/rspec/scaffold/templates/index_spec.rb b/lib/generators/rspec/scaffold/templates/index_spec.rb index e813cfa91c..3c1d41863b 100644 --- a/lib/generators/rspec/scaffold/templates/index_spec.rb +++ b/lib/generators/rspec/scaffold/templates/index_spec.rb @@ -7,7 +7,7 @@ <% [1,2].each_with_index do |id, model_index| -%> <%= class_name %>.create!(<%= output_attributes.empty? ? (model_index == 1 ? ')' : '),') : '' %> <% output_attributes.each_with_index do |attribute, attribute_index| -%> - :<%= attribute.name %> => <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%> + <%= attribute.name %>: <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%> <% end -%> <% if !output_attributes.empty? -%> <%= model_index == 1 ? ')' : '),' %> @@ -19,7 +19,7 @@ it "renders a list of <%= ns_table_name %>" do render <% for attribute in output_attributes -%> - assert_select "tr>td", :text => <%= value_for(attribute) %>.to_s, :count => 2 + assert_select "tr>td", text: <%= value_for(attribute) %>.to_s, :count => 2 <% end -%> end end diff --git a/lib/generators/rspec/scaffold/templates/new_spec.rb b/lib/generators/rspec/scaffold/templates/new_spec.rb index 2fe5c1367d..3756604a24 100644 --- a/lib/generators/rspec/scaffold/templates/new_spec.rb +++ b/lib/generators/rspec/scaffold/templates/new_spec.rb @@ -5,7 +5,7 @@ before(:each) do assign(:<%= ns_file_name %>, <%= class_name %>.new(<%= '))' if output_attributes.empty? %> <% output_attributes.each_with_index do |attribute, attribute_index| -%> - :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%> + <%= attribute.name %>: <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%> <% end -%> <%= !output_attributes.empty? ? " ))\n end" : " end" %> diff --git a/lib/generators/rspec/scaffold/templates/routing_spec.rb b/lib/generators/rspec/scaffold/templates/routing_spec.rb index a81d765a21..265ecd4f3f 100644 --- a/lib/generators/rspec/scaffold/templates/routing_spec.rb +++ b/lib/generators/rspec/scaffold/templates/routing_spec.rb @@ -5,41 +5,41 @@ describe "routing" do <% unless options[:singleton] -%> it "routes to #index" do - expect(:get => "/<%= ns_table_name %>").to route_to("<%= ns_table_name %>#index") + expect(get: "/<%= ns_table_name %>").to route_to("<%= ns_table_name %>#index") end <% end -%> <% unless options[:api] -%> it "routes to #new" do - expect(:get => "/<%= ns_table_name %>/new").to route_to("<%= ns_table_name %>#new") + expect(get: "/<%= ns_table_name %>/new").to route_to("<%= ns_table_name %>#new") end <% end -%> it "routes to #show" do - expect(:get => "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#show", :id => "1") + expect(get: "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#show", id: "1") end <% unless options[:api] -%> it "routes to #edit" do - expect(:get => "/<%= ns_table_name %>/1/edit").to route_to("<%= ns_table_name %>#edit", :id => "1") + expect(get: "/<%= ns_table_name %>/1/edit").to route_to("<%= ns_table_name %>#edit", id: "1") end <% end -%> it "routes to #create" do - expect(:post => "/<%= ns_table_name %>").to route_to("<%= ns_table_name %>#create") + expect(post: "/<%= ns_table_name %>").to route_to("<%= ns_table_name %>#create") end it "routes to #update via PUT" do - expect(:put => "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#update", :id => "1") + expect(put: "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#update", id: "1") end it "routes to #update via PATCH" do - expect(:patch => "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#update", :id => "1") + expect(patch: "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#update", id: "1") end it "routes to #destroy" do - expect(:delete => "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#destroy", :id => "1") + expect(delete: "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#destroy", id: "1") end end end diff --git a/lib/generators/rspec/scaffold/templates/show_spec.rb b/lib/generators/rspec/scaffold/templates/show_spec.rb index 90247c5c18..15811dea5a 100644 --- a/lib/generators/rspec/scaffold/templates/show_spec.rb +++ b/lib/generators/rspec/scaffold/templates/show_spec.rb @@ -5,7 +5,7 @@ before(:each) do @<%= ns_file_name %> = assign(:<%= ns_file_name %>, <%= class_name %>.create!(<%= '))' if output_attributes.empty? %> <% output_attributes.each_with_index do |attribute, attribute_index| -%> - :<%= attribute.name %> => <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%> + <%= attribute.name %>: <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%> <% end -%> <% if !output_attributes.empty? -%> )) diff --git a/lib/generators/rspec/system/system_generator.rb b/lib/generators/rspec/system/system_generator.rb index 937241733e..ca994bf4b7 100644 --- a/lib/generators/rspec/system/system_generator.rb +++ b/lib/generators/rspec/system/system_generator.rb @@ -5,7 +5,7 @@ module Rspec module Generators # @private class SystemGenerator < Base - class_option :system_specs, :type => :boolean, :default => true, :desc => "Generate system specs" + class_option :system_specs, type: :boolean, default: true, desc: "Generate system specs" def generate_system_spec return unless options[:system_specs] diff --git a/lib/generators/rspec/view/view_generator.rb b/lib/generators/rspec/view/view_generator.rb index 7a7c002c22..5de24267e5 100644 --- a/lib/generators/rspec/view/view_generator.rb +++ b/lib/generators/rspec/view/view_generator.rb @@ -4,9 +4,9 @@ module Rspec module Generators # @private class ViewGenerator < Base - argument :actions, :type => :array, :default => [], :banner => "action action" + argument :actions, type: :array, default: [], banner: "action action" - class_option :template_engine, :desc => "Template engine to generate view files" + class_option :template_engine, desc: "Template engine to generate view files" def create_view_specs empty_directory File.join("spec", "views", file_path)