From 62fedf1a1e8f9d67fa173e3756fec38e7d68c190 Mon Sep 17 00:00:00 2001 From: Tanbir Hasan Date: Thu, 31 Oct 2019 18:07:57 +0600 Subject: [PATCH] Update rocket hash --- Capybara.md | 2 +- Changelog.md | 8 +-- Gemfile | 8 +-- .../matchers/have_broadcasted_matcher.feature | 2 +- .../have_enqueued_mail_matcher.feature | 2 +- .../rspec/scaffold/templates/index_spec.rb | 2 +- lib/rspec-rails.rb | 2 +- lib/rspec/rails/configuration.rb | 64 +++++++++---------- .../rails/example/controller_example_group.rb | 8 +-- .../rails/example/feature_example_group.rb | 8 +-- lib/rspec/rails/example/view_example_group.rb | 12 ++-- .../rails/fixture_file_upload_support.rb | 2 +- lib/rspec/rails/matchers/action_cable.rb | 2 +- lib/rspec/rails/matchers/have_http_status.rb | 6 +- lib/rspec/rails/matchers/routing_matchers.rb | 20 +++--- lib/rspec/rails/tasks/rspec.rake | 8 +-- lib/rspec/rails/vendor/capybara.rb | 20 +++--- lib/rspec/rails/view_rendering.rb | 6 +- .../controller/controller_generator_spec.rb | 2 +- .../rspec/scaffold/scaffold_generator_spec.rb | 10 +-- spec/rspec/rails/configuration_spec.rb | 36 +++++------ .../example/routing_example_group_spec.rb | 6 +- .../rails/matchers/be_new_record_spec.rb | 4 +- .../rails/matchers/have_enqueued_mail_spec.rb | 26 ++++---- 24 files changed, 133 insertions(+), 133 deletions(-) diff --git a/Capybara.md b/Capybara.md index c448f130c4..2936a242cf 100644 --- a/Capybara.md +++ b/Capybara.md @@ -73,5 +73,5 @@ behavior and accepting the risks associated with doing so: # not recommended! RSpec.configure do |c| - c.include Capybara::DSL, :file_path => "spec/requests" + c.include Capybara::DSL, file_path: "spec/requests" end diff --git a/Changelog.md b/Changelog.md index b5895adc07..65875591d7 100644 --- a/Changelog.md +++ b/Changelog.md @@ -344,10 +344,10 @@ Enhancements: * Improve controller and routing spec calls to `routes` by using `yield` instead of `call`. (Anton Davydov, #1308) * Add support for `ActiveJob` specs as standard `RSpec::Rails::RailsExampleGoup`s - via both `:type => :job` and inferring type from spec directory `spec/jobs`. + via both `type: :job` and inferring type from spec directory `spec/jobs`. (Gabe Martin-Dempesy, #1361) * Include `RSpec::Rails::FixtureSupport` into example groups using metadata - `:use_fixtures => true`. (Aaron Kromer, #1372) + `use_fixtures: true`. (Aaron Kromer, #1372) * Include `rspec:request` generator for generating request specs; this is an alias of `rspec:integration` (Aaron Kromer, #1378) * Update `rails_helper` generator with a default check to abort the spec run @@ -488,7 +488,7 @@ Enhancements: Bug Fixes: * Fix an inconsistency in the generated scaffold specs for a controller. (Andy Waite) -* Ensure `config.before(:all, :type => )` hooks run before groups +* Ensure `config.before(:all, type: )` hooks run before groups of the given type, even when the type is inferred by the file location. (Jon Rowe, Myron Marston) * 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 * Enhancements * include ApplicationHelper in helper object in helper specs * include request spec extensions in files in spec/integration - * include controller spec extensions in groups that use :type => :controller + * include controller spec extensions in groups that use type: :controller * same for :model, :view, :helper, :mailer, :request, :routing * Bug fixes diff --git a/Gemfile b/Gemfile index ec02a32457..5f0f8a13b5 100644 --- a/Gemfile +++ b/Gemfile @@ -7,12 +7,12 @@ gemspec rspec_dependencies_gemfile = File.expand_path("../Gemfile-rspec-dependencies", __FILE__) eval_gemfile rspec_dependencies_gemfile -gem 'yard', '~> 0.8.7', :require => false +gem 'yard', '~> 0.8.7', require: false ### deps for rdoc.info group :documentation do - gem 'redcarpet', '~> 3.4.0', platforms: [:ruby] gem 'github-markup', '~> 3.0.3' + gem 'redcarpet', '~> 3.4.0', platforms: [:ruby] gem 'relish', '~> 0.7.1' end @@ -36,8 +36,8 @@ else end if MAJOR >= 6 + gem 'selenium-webdriver', '~> 3.5', require: false gem 'sqlite3', '~> 1.4', platforms: [:ruby] - gem 'selenium-webdriver', '~> 3.5', :require => false else gem 'sqlite3', '~> 1.3.6', platforms: [:ruby] end @@ -57,7 +57,7 @@ if RUBY_VERSION < '2.4.0' gem 'minitest', '< 5.12.0' end -gem 'capybara', '~> 2.13', :require => false +gem 'capybara', '~> 2.13', require: false if MAJOR < 6 gem 'nokogiri', '1.8.5' diff --git a/features/matchers/have_broadcasted_matcher.feature b/features/matchers/have_broadcasted_matcher.feature index f83fd6af20..ecacadafe9 100644 --- a/features/matchers/have_broadcasted_matcher.feature +++ b/features/matchers/have_broadcasted_matcher.feature @@ -104,7 +104,7 @@ Feature: have_broadcasted matcher """ruby require "rails_helper" - RSpec.describe ChatChannel, :type => :channel do + RSpec.describe ChatChannel, type: :channel do it "successfully subscribes" do user = User.new(42) diff --git a/features/matchers/have_enqueued_mail_matcher.feature b/features/matchers/have_enqueued_mail_matcher.feature index e1ebbf886e..c8fc5031b4 100644 --- a/features/matchers/have_enqueued_mail_matcher.feature +++ b/features/matchers/have_enqueued_mail_matcher.feature @@ -33,7 +33,7 @@ Feature: have_enqueued_mail matcher it "matches with enqueued mailer" do ActiveJob::Base.queue_adapter = :test expect { - NotificationsMailer.signup.deliver_later(:wait_until => Date.tomorrow.noon) + NotificationsMailer.signup.deliver_later(wait_until: Date.tomorrow.noon) }.to have_enqueued_mail.at(Date.tomorrow.noon) end end diff --git a/lib/generators/rspec/scaffold/templates/index_spec.rb b/lib/generators/rspec/scaffold/templates/index_spec.rb index 3c1d41863b..fc5a0f285b 100644 --- a/lib/generators/rspec/scaffold/templates/index_spec.rb +++ b/lib/generators/rspec/scaffold/templates/index_spec.rb @@ -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/rspec-rails.rb b/lib/rspec-rails.rb index 2cabaaf16a..707e3b6d99 100644 --- a/lib/rspec-rails.rb +++ b/lib/rspec-rails.rb @@ -31,7 +31,7 @@ class Railtie < ::Rails::Railtie # This is called after the environment has been loaded but before Rails # sets the default for the `preview_path` initializer "rspec_rails.action_mailer", - :before => "action_mailer.set_configs" do |app| + before: "action_mailer.set_configs" do |app| setup_preview_path(app) end diff --git a/lib/rspec/rails/configuration.rb b/lib/rspec/rails/configuration.rb index 38d67f9501..657f08882e 100644 --- a/lib/rspec/rails/configuration.rb +++ b/lib/rspec/rails/configuration.rb @@ -25,33 +25,33 @@ class Configuration # # @api private DIRECTORY_MAPPINGS = { - :channel => %w[spec channels], - :controller => %w[spec controllers], - :helper => %w[spec helpers], - :job => %w[spec jobs], - :mailer => %w[spec mailers], - :model => %w[spec models], - :request => %w[spec (requests|integration|api)], - :routing => %w[spec routing], - :view => %w[spec views], - :feature => %w[spec features], - :system => %w[spec system], - :mailbox => %w[spec mailboxes] + channel: %w[spec channels], + controller: %w[spec controllers], + helper: %w[spec helpers], + job: %w[spec jobs], + mailer: %w[spec mailers], + model: %w[spec models], + request: %w[spec (requests|integration|api)], + routing: %w[spec routing], + view: %w[spec views], + feature: %w[spec features], + system: %w[spec system], + mailbox: %w[spec mailboxes] } # Sets up the different example group modules for the different spec types # # @api private def self.add_test_type_configurations(config) - config.include RSpec::Rails::ControllerExampleGroup, :type => :controller - config.include RSpec::Rails::HelperExampleGroup, :type => :helper - config.include RSpec::Rails::ModelExampleGroup, :type => :model - config.include RSpec::Rails::RequestExampleGroup, :type => :request - config.include RSpec::Rails::RoutingExampleGroup, :type => :routing - config.include RSpec::Rails::ViewExampleGroup, :type => :view - config.include RSpec::Rails::FeatureExampleGroup, :type => :feature + config.include RSpec::Rails::ControllerExampleGroup, type: :controller + config.include RSpec::Rails::HelperExampleGroup, type: :helper + config.include RSpec::Rails::ModelExampleGroup, type: :model + config.include RSpec::Rails::RequestExampleGroup, type: :request + config.include RSpec::Rails::RoutingExampleGroup, type: :routing + config.include RSpec::Rails::ViewExampleGroup, type: :view + config.include RSpec::Rails::FeatureExampleGroup, type: :feature config.include RSpec::Rails::Matchers - config.include RSpec::Rails::SystemExampleGroup, :type => :system + config.include RSpec::Rails::SystemExampleGroup, type: :system end # @private @@ -61,10 +61,10 @@ def self.initialize_configuration(config) config.backtrace_exclusion_patterns << %r{lib/rspec/rails} # controller settings - config.add_setting :infer_base_class_for_anonymous_controllers, :default => true + config.add_setting :infer_base_class_for_anonymous_controllers, default: true # fixture support - config.add_setting :use_transactional_fixtures, :alias_with => :use_transactional_examples + config.add_setting :use_transactional_fixtures, alias_with: :use_transactional_examples config.add_setting :use_instantiated_fixtures config.add_setting :global_fixtures config.add_setting :fixture_path @@ -80,7 +80,7 @@ def self.initialize_configuration(config) config.include RSpec::Rails::FixtureSupport if ::Rails::VERSION::STRING > '5' - config.add_setting :file_fixture_path, :default => 'spec/fixtures/files' + config.add_setting :file_fixture_path, default: 'spec/fixtures/files' config.include RSpec::Rails::FileFixtureSupport end @@ -93,7 +93,7 @@ def self.initialize_configuration(config) # as a getter. This makes it easier for rspec-rails users because we use # `render_views` directly in example groups, so this aligns the two APIs, # but requires this workaround: - config.add_setting :rendering_views, :default => false + config.add_setting :rendering_views, default: false config.instance_exec do def render_views=(val) @@ -111,7 +111,7 @@ def render_views? def infer_spec_type_from_file_location! DIRECTORY_MAPPINGS.each do |type, dir_parts| escaped_path = Regexp.compile(dir_parts.join('[\\\/]') + '[\\\/]') - define_derived_metadata(:file_path => escaped_path) do |metadata| + define_derived_metadata(file_path: escaped_path) do |metadata| metadata[:type] ||= type end end @@ -129,26 +129,26 @@ def filter_rails_from_backtrace! if defined?(::Rails::Controller::Testing) [:controller, :view, :request].each do |type| - config.include ::Rails::Controller::Testing::TestProcess, :type => type - config.include ::Rails::Controller::Testing::TemplateAssertions, :type => type - config.include ::Rails::Controller::Testing::Integration, :type => type + config.include ::Rails::Controller::Testing::TestProcess, type: type + config.include ::Rails::Controller::Testing::TemplateAssertions, type: type + config.include ::Rails::Controller::Testing::Integration, type: type end end if RSpec::Rails::FeatureCheck.has_action_mailer? - config.include RSpec::Rails::MailerExampleGroup, :type => :mailer + config.include RSpec::Rails::MailerExampleGroup, type: :mailer end if RSpec::Rails::FeatureCheck.has_active_job? - config.include RSpec::Rails::JobExampleGroup, :type => :job + config.include RSpec::Rails::JobExampleGroup, type: :job end if RSpec::Rails::FeatureCheck.has_action_cable_testing? - config.include RSpec::Rails::ChannelExampleGroup, :type => :channel + config.include RSpec::Rails::ChannelExampleGroup, type: :channel end if RSpec::Rails::FeatureCheck.has_action_mailbox? - config.include RSpec::Rails::MailboxExampleGroup, :type => :mailbox + config.include RSpec::Rails::MailboxExampleGroup, type: :mailbox end end # rubocop:enable Metrics/MethodLength diff --git a/lib/rspec/rails/example/controller_example_group.rb b/lib/rspec/rails/example/controller_example_group.rb index 198f22ab5f..3150f3d469 100644 --- a/lib/rspec/rails/example/controller_example_group.rb +++ b/lib/rspec/rails/example/controller_example_group.rb @@ -94,9 +94,9 @@ def self.name self.routes = ActionDispatch::Routing::RouteSet.new.tap do |r| r.draw do resources resource_name, - :as => resource_as, - :module => resource_module, - :path => resource_path + as: resource_as, + module: resource_module, + path: resource_path end end end @@ -159,7 +159,7 @@ def rescue_with_handler(exception) # # expect do # bypass_rescue - # get :show, :id => profile.id + 1 + # get :show, id: profile.id + 1 # end.to raise_error(/403 Forbidden/) # end # end diff --git a/lib/rspec/rails/example/feature_example_group.rb b/lib/rspec/rails/example/feature_example_group.rb index 06ae978503..9cee0120e0 100644 --- a/lib/rspec/rails/example/feature_example_group.rb +++ b/lib/rspec/rails/example/feature_example_group.rb @@ -37,9 +37,9 @@ def visit(*) unless RSpec.respond_to?(:feature) opts = { - :capybara_feature => true, - :type => :feature, - :skip => <<-EOT.squish + capybara_feature: true, + type: :feature, + skip: <<-EOT.squish Feature specs require the Capybara (https://github.com/jnicklas/capybara) gem, version 2.2.0 or later. We recommend version 2.4.0 or later to avoid some deprecation warnings and have support for @@ -63,7 +63,7 @@ def visit(*) main_feature = nil unless c.expose_dsl_globally? c.alias_example_group_to :feature, opts c.alias_example_to :scenario - c.alias_example_to :xscenario, :skip => 'Temporarily skipped with xscenario' + c.alias_example_to :xscenario, skip: 'Temporarily skipped with xscenario' end # Due to load order issues and `config.expose_dsl_globally?` defaulting to diff --git a/lib/rspec/rails/example/view_example_group.rb b/lib/rspec/rails/example/view_example_group.rb index 39ef6a8365..93a2033f9d 100644 --- a/lib/rspec/rails/example/view_example_group.rb +++ b/lib/rspec/rails/example/view_example_group.rb @@ -50,9 +50,9 @@ module ExampleMethods end # @overload render - # @overload render({:partial => path_to_file}) - # @overload render({:partial => path_to_file}, {... locals ...}) - # @overload render({:partial => path_to_file}, {... locals ...}) do ... end + # @overload render({partial: path_to_file}) + # @overload render({partial: path_to_file}, {... locals ...}) + # @overload render({partial: path_to_file}, {... locals ...}) do ... end # # Delegates to ActionView::Base#render, so see documentation on that # for more info. @@ -62,7 +62,7 @@ module ExampleMethods # # describe "widgets/new.html.erb" do # it "shows all the widgets" do - # render # => view.render(:file => "widgets/new.html.erb") + # render # => view.render(file: "widgets/new.html.erb") # # ... # end # end @@ -105,7 +105,7 @@ def params # @deprecated Use `view` instead. def template - RSpec.deprecate("template", :replacement => "view") + RSpec.deprecate("template", replacement: "view") view end @@ -152,7 +152,7 @@ def _default_render_options # the original string. match = path_regex.match(_default_file_to_render) - render_options = { :template => match[:template] } + render_options = { template: match[:template] } render_options[:handlers] = [match[:handler]] if match[:handler] render_options[:formats] = [match[:format].to_sym] if match[:format] render_options[:locales] = [match[:locale]] if match[:locale] diff --git a/lib/rspec/rails/fixture_file_upload_support.rb b/lib/rspec/rails/fixture_file_upload_support.rb index c222eeaf0b..ade379bc38 100644 --- a/lib/rspec/rails/fixture_file_upload_support.rb +++ b/lib/rspec/rails/fixture_file_upload_support.rb @@ -2,7 +2,7 @@ module RSpec module Rails # @private module FixtureFileUploadSupport - delegate :fixture_file_upload, :to => :rails_fixture_file_wrapper + delegate :fixture_file_upload, to: :rails_fixture_file_wrapper private diff --git a/lib/rspec/rails/matchers/action_cable.rb b/lib/rspec/rails/matchers/action_cable.rb index 42534b59c0..12b811d7b4 100644 --- a/lib/rspec/rails/matchers/action_cable.rb +++ b/lib/rspec/rails/matchers/action_cable.rb @@ -48,7 +48,7 @@ module ActionCable def have_broadcasted_to(target = nil) check_action_cable_adapter - ActionCable::HaveBroadcastedTo.new(target, :channel => described_class) + ActionCable::HaveBroadcastedTo.new(target, channel: described_class) end alias_method :broadcast_to, :have_broadcasted_to diff --git a/lib/rspec/rails/matchers/have_http_status.rb b/lib/rspec/rails/matchers/have_http_status.rb index 2a6d77bc84..5e67280aaa 100644 --- a/lib/rspec/rails/matchers/have_http_status.rb +++ b/lib/rspec/rails/matchers/have_http_status.rb @@ -293,9 +293,9 @@ def failure_message_when_negated protected RESPONSE_METHODS = { - :success => 'successful', - :error => 'server_error', - :missing => 'not_found' + success: 'successful', + error: 'server_error', + missing: 'not_found' }.freeze def check_expected_status(test_response, expected) diff --git a/lib/rspec/rails/matchers/routing_matchers.rb b/lib/rspec/rails/matchers/routing_matchers.rb index 9bca99eda5..621b06b00e 100644 --- a/lib/rspec/rails/matchers/routing_matchers.rb +++ b/lib/rspec/rails/matchers/routing_matchers.rb @@ -14,7 +14,7 @@ def initialize(scope, *expected) @expected.merge!(expected[0]) else controller, action = expected[0].split('#') - @expected.merge!(:controller => controller, :action => action) + @expected.merge!(controller: controller, action: action) end end @@ -26,7 +26,7 @@ def matches?(verb_to_path_map) path, query = *verb_to_path_map.values.first.split('?') @scope.assert_recognizes( @expected, - { :method => verb_to_path_map.keys.first, :path => path }, + { method: verb_to_path_map.keys.first, path: path }, Rack::Utils.parse_nested_query(query) ) end @@ -50,12 +50,12 @@ def description # # @example # - # expect(:get => "/things/special").to route_to( - # :controller => "things", - # :action => "special" + # expect(get: "/things/special").to route_to( + # controller: "things", + # action: "special" # ) # - # expect(:get => "/things/special").to route_to("things#special") + # expect(get: "/things/special").to route_to("things#special") # # @see https://api.rubyonrails.org/classes/ActionDispatch/Assertions/RoutingAssertions.html#method-i-assert_recognizes def route_to(*expected) @@ -72,7 +72,7 @@ def matches?(path) @actual = path match_unless_raises ActionController::RoutingError do @routing_options = @scope.routes.recognize_path( - path.values.first, :method => path.keys.first + path.values.first, method: path.keys.first ) end end @@ -95,9 +95,9 @@ def description # `RouteSet#recognize_path`. # # @example You can use route helpers provided by rspec-rails. - # expect(:get => "/a/path").to be_routable - # expect(:post => "/another/path").to be_routable - # expect(:put => "/yet/another/path").to be_routable + # expect(get: "/a/path").to be_routable + # expect(post: "/another/path").to be_routable + # expect(put: "/yet/another/path").to be_routable def be_routable BeRoutableMatcher.new(self) end diff --git a/lib/rspec/rails/tasks/rspec.rake b/lib/rspec/rails/tasks/rspec.rake index 339de95bc6..a58a518ffb 100644 --- a/lib/rspec/rails/tasks/rspec.rake +++ b/lib/rspec/rails/tasks/rspec.rake @@ -3,12 +3,12 @@ if default = Rake.application.instance_variable_get('@tasks')['default'] default.prerequisites.delete('test') end -task :default => :spec +task default: :spec -task :stats => "spec:statsetup" +task stats: "spec:statsetup" desc "Run all specs in spec directory (excluding plugin specs)" -RSpec::Core::RakeTask.new(:spec => "spec:prepare") +RSpec::Core::RakeTask.new(spec: "spec:prepare") namespace :spec do types = begin @@ -38,7 +38,7 @@ namespace :spec do # RCov task only enabled for Ruby 1.8 if RUBY_VERSION < '1.9' desc "Run all specs with rcov" - RSpec::Core::RakeTask.new(:rcov => "spec:prepare") do |t| + RSpec::Core::RakeTask.new(rcov: "spec:prepare") do |t| t.rcov = true t.pattern = "./spec/**/*_spec.rb" t.rcov_opts = '--exclude /gems/,/Library/,/usr/,lib/tasks,.bundle,config,/lib/rspec/,/lib/rspec-,spec' diff --git a/lib/rspec/rails/vendor/capybara.rb b/lib/rspec/rails/vendor/capybara.rb index 996a42b114..1d3124c79a 100644 --- a/lib/rspec/rails/vendor/capybara.rb +++ b/lib/rspec/rails/vendor/capybara.rb @@ -16,24 +16,24 @@ RSpec.configure do |c| if defined?(Capybara::DSL) - c.include Capybara::DSL, :type => :feature + c.include Capybara::DSL, type: :feature if defined?(ActionPack) && ActionPack::VERSION::STRING >= "5.1" - c.include Capybara::DSL, :type => :system + c.include Capybara::DSL, type: :system end end if defined?(Capybara::RSpecMatchers) - c.include Capybara::RSpecMatchers, :type => :view - c.include Capybara::RSpecMatchers, :type => :helper - c.include Capybara::RSpecMatchers, :type => :mailer - c.include Capybara::RSpecMatchers, :type => :controller - c.include Capybara::RSpecMatchers, :type => :feature - c.include Capybara::RSpecMatchers, :type => :system + c.include Capybara::RSpecMatchers, type: :view + c.include Capybara::RSpecMatchers, type: :helper + c.include Capybara::RSpecMatchers, type: :mailer + c.include Capybara::RSpecMatchers, type: :controller + c.include Capybara::RSpecMatchers, type: :feature + c.include Capybara::RSpecMatchers, type: :system end unless defined?(Capybara::RSpecMatchers) || defined?(Capybara::DSL) - c.include Capybara, :type => :request - c.include Capybara, :type => :controller + c.include Capybara, type: :request + c.include Capybara, type: :controller end end end diff --git a/lib/rspec/rails/view_rendering.rb b/lib/rspec/rails/view_rendering.rb index 79b5139d87..22eff75ba2 100644 --- a/lib/rspec/rails/view_rendering.rb +++ b/lib/rspec/rails/view_rendering.rb @@ -55,9 +55,9 @@ def self.nullify_template_rendering(templates) "", template.identifier, EmptyTemplateHandler, - :virtual_path => template.virtual_path, - :format => template_format(template), - :locals => [] + virtual_path: template.virtual_path, + format: template_format(template), + locals: [] ) end end diff --git a/spec/generators/rspec/controller/controller_generator_spec.rb b/spec/generators/rspec/controller/controller_generator_spec.rb index 861aa54c3b..80bd53d9d5 100644 --- a/spec/generators/rspec/controller/controller_generator_spec.rb +++ b/spec/generators/rspec/controller/controller_generator_spec.rb @@ -116,7 +116,7 @@ it { is_expected.to contain(/^RSpec.describe 'PostsController', #{type_metatag(:routing)}/) } it { is_expected.to contain(/describe 'routing'/) } it { is_expected.to contain(/it 'routes to #seek'/) } - it { is_expected.to contain(/expect\(:get => "\/posts\/seek"\).to route_to\("posts#seek"\)/) } + it { is_expected.to contain(/expect\(get: "\/posts\/seek"\).to route_to\("posts#seek"\)/) } end end diff --git a/spec/generators/rspec/scaffold/scaffold_generator_spec.rb b/spec/generators/rspec/scaffold/scaffold_generator_spec.rb index a6a4ccc459..3fc754b26c 100644 --- a/spec/generators/rspec/scaffold/scaffold_generator_spec.rb +++ b/spec/generators/rspec/scaffold/scaffold_generator_spec.rb @@ -2,7 +2,7 @@ require 'generators/rspec/scaffold/scaffold_generator' require 'support/generators' -RSpec.describe Rspec::Generators::ScaffoldGenerator, :type => :generator do +RSpec.describe Rspec::Generators::ScaffoldGenerator, type: :generator do setup_default_destination describe 'standard controller spec' do @@ -98,16 +98,16 @@ before { run_generator %w(posts upvotes:integer downvotes:integer) } subject { file("spec/views/posts/index.html.erb_spec.rb") } it { is_expected.to exist } - it { is_expected.to contain('assert_select "tr>td", :text => 2.to_s, :count => 2') } - it { is_expected.to contain('assert_select "tr>td", :text => 3.to_s, :count => 2') } + it { is_expected.to contain('assert_select "tr>td", text: 2.to_s, count: 2') } + it { is_expected.to contain('assert_select "tr>td", text: 3.to_s, count: 2') } end describe 'with multiple float attributes index' do before { run_generator %w(posts upvotes:float downvotes:float) } subject { file("spec/views/posts/index.html.erb_spec.rb") } it { is_expected.to exist } - it { is_expected.to contain('assert_select "tr>td", :text => 2.5.to_s, :count => 2') } - it { is_expected.to contain('assert_select "tr>td", :text => 3.5.to_s, :count => 2') } + it { is_expected.to contain('assert_select "tr>td", text: 2.5.to_s, count: 2') } + it { is_expected.to contain('assert_select "tr>td", text: 3.5.to_s, count: 2') } end case diff --git a/spec/rspec/rails/configuration_spec.rb b/spec/rspec/rails/configuration_spec.rb index 5538eeffa8..3b904cd97b 100644 --- a/spec/rspec/rails/configuration_spec.rb +++ b/spec/rspec/rails/configuration_spec.rb @@ -59,11 +59,11 @@ context "adds settings" do include_examples "adds setting", :infer_base_class_for_anonymous_controllers, - :default => true + default: true include_examples "adds setting", :use_transactional_fixtures, - :alias_with => :use_transactional_examples + alias_with: :use_transactional_examples include_examples "adds setting", :use_instantiated_fixtures @@ -131,7 +131,7 @@ def in_inferring_type_from_location_environment "./#{location}/foos_spec.rb" ) group = RSpec.describe("Arbitrary Description") - expect(group.metadata).to include(:type => type) + expect(group.metadata).to include(type: type) end end end @@ -167,17 +167,17 @@ def in_inferring_type_from_location_environment a_controller_class = Class.new stub_const "SomeController", a_controller_class - group = RSpec.describe(SomeController, :type => :controller) + group = RSpec.describe(SomeController, type: :controller) expect(group.controller_class).to be(a_controller_class) expect(group.new).to be_a(RSpec::Rails::ControllerExampleGroup) end - it "metadata `:type => :helper` sets up helper example groups" do + it "metadata `type: :helper` sets up helper example groups" do a_helper_module = Module.new stub_const "SomeHelper", a_helper_module - group = RSpec.describe(SomeHelper, :type => :helper) + group = RSpec.describe(SomeHelper, type: :helper) expect( group.determine_default_helper_class(:ignored) @@ -185,16 +185,16 @@ def in_inferring_type_from_location_environment expect(group.new).to be_a(RSpec::Rails::HelperExampleGroup) end - it "metadata `:type => :model` sets up model example groups" do + it "metadata `type: :model` sets up model example groups" do a_model_class = Class.new stub_const "SomeModel", a_model_class - group = RSpec.describe(SomeModel, :type => :model) + group = RSpec.describe(SomeModel, type: :model) expect(group.new).to be_a(RSpec::Rails::ModelExampleGroup) end - it "metadata `:type => :request` sets up request example groups" do + it "metadata `type: :request` sets up request example groups" do a_rails_app = double("Rails application") the_rails_module = Module.new allow(the_rails_module).to receive(:application) { a_rails_app } @@ -202,33 +202,33 @@ def in_inferring_type_from_location_environment stub_const "Rails", the_rails_module stub_const 'Rails::VERSION', version - group = RSpec.describe("Some Request API", :type => :request) + group = RSpec.describe("Some Request API", type: :request) expect(group.new.app).to be(a_rails_app) expect(group.new).to be_a(RSpec::Rails::RequestExampleGroup) end - it "metadata `:type => :routing` sets up routing example groups" do + it "metadata `type: :routing` sets up routing example groups" do a_controller_class = Class.new stub_const "SomeController", a_controller_class - group = RSpec.describe(SomeController, :type => :routing) + group = RSpec.describe(SomeController, type: :routing) expect(group).to respond_to(:routes) expect(group.new).to be_a(RSpec::Rails::RoutingExampleGroup) end - it "metadata `:type => :view` sets up view example groups" do + it "metadata `type: :view` sets up view example groups" do a_helper_module = Module.new stub_const "SomeControllerHelper", a_helper_module - group = RSpec.describe("some_controller/action.html.erb", :type => :view) + group = RSpec.describe("some_controller/action.html.erb", type: :view) expect(group._default_helper).to be(a_helper_module) expect(group.new).to be_a(RSpec::Rails::ViewExampleGroup) end - it "metadata `:type => :feature` sets up feature example groups" do + it "metadata `type: :feature` sets up feature example groups" do a_rails_app = double("Rails application") the_rails_module = Module.new allow(the_rails_module).to receive(:application) { a_rails_app } @@ -236,7 +236,7 @@ def in_inferring_type_from_location_environment stub_const "Rails", the_rails_module stub_const 'Rails::VERSION', version - group = RSpec.describe("Some feature description", :type => :feature) + group = RSpec.describe("Some feature description", type: :feature) example = group.new expect(example).to respond_to(:visit) @@ -244,10 +244,10 @@ def in_inferring_type_from_location_environment end if defined?(ActionMailer) - it "metadata `:type => :mailer` sets up mailer example groups" do + it "metadata `type: :mailer` sets up mailer example groups" do a_mailer_class = Class.new stub_const "SomeMailer", a_mailer_class - group = RSpec.describe(SomeMailer, :type => :mailer) + group = RSpec.describe(SomeMailer, type: :mailer) expect(group.mailer_class).to be(a_mailer_class) expect(group.new).to be_a(RSpec::Rails::MailerExampleGroup) end diff --git a/spec/rspec/rails/example/routing_example_group_spec.rb b/spec/rspec/rails/example/routing_example_group_spec.rb index 3e3593cf6e..ebc42dafcf 100644 --- a/spec/rspec/rails/example/routing_example_group_spec.rb +++ b/spec/rspec/rails/example/routing_example_group_spec.rb @@ -14,9 +14,9 @@ module RSpec::Rails example = group.new # Yes, this is quite invasive - url_helpers = double('url_helpers', :foo_path => "foo") - routes = double('routes', :url_helpers => url_helpers) - allow(example).to receive_messages(:routes => routes) + url_helpers = double('url_helpers', foo_path: "foo") + routes = double('routes', url_helpers: url_helpers) + allow(example).to receive_messages(routes: routes) expect(example.foo_path).to eq("foo") end diff --git a/spec/rspec/rails/matchers/be_new_record_spec.rb b/spec/rspec/rails/matchers/be_new_record_spec.rb index 7e38c7faf4..5b4213e39d 100644 --- a/spec/rspec/rails/matchers/be_new_record_spec.rb +++ b/spec/rspec/rails/matchers/be_new_record_spec.rb @@ -2,7 +2,7 @@ describe "be_new_record" do context "a new record" do - let(:record) { double('record', :new_record? => true) } + let(:record) { double('record', new_record?: true) } it "passes" do expect(record).to be_new_record @@ -16,7 +16,7 @@ end context "a persisted record" do - let(:record) { double('record', :new_record? => false) } + let(:record) { double('record', new_record?: false) } it "fails" do expect(record).not_to be_new_record diff --git a/spec/rspec/rails/matchers/have_enqueued_mail_spec.rb b/spec/rspec/rails/matchers/have_enqueued_mail_spec.rb index 749d521d43..871092a879 100644 --- a/spec/rspec/rails/matchers/have_enqueued_mail_spec.rb +++ b/spec/rspec/rails/matchers/have_enqueued_mail_spec.rb @@ -25,7 +25,7 @@ def email_with_args(arg1, arg2); end end end -RSpec.describe "HaveEnqueuedMail matchers", :skip => !RSpec::Rails::FeatureCheck.has_active_job? do +RSpec.describe "HaveEnqueuedMail matchers", skip: !RSpec::Rails::FeatureCheck.has_active_job? do before do ActiveJob::Base.queue_adapter = :test end @@ -240,7 +240,7 @@ def email_with_args(arg1, arg2); end send_time = Date.tomorrow.noon expect { - TestMailer.test_email.deliver_later(:wait_until => send_time) + TestMailer.test_email.deliver_later(wait_until: send_time) }.to have_enqueued_email(TestMailer, :test_email).at(send_time) end @@ -249,7 +249,7 @@ def email_with_args(arg1, arg2); end expect { expect { - TestMailer.test_email.deliver_later(:wait_until => send_time + 1) + TestMailer.test_email.deliver_later(wait_until: send_time + 1) }.to have_enqueued_email(TestMailer, :test_email).at(send_time) }.to raise_error(/expected to enqueue TestMailer.test_email exactly 1 time at #{send_time.strftime('%F %T')}/) end @@ -259,20 +259,20 @@ def email_with_args(arg1, arg2); end slightly_earlier = 58.seconds.from_now expect { - TestMailer.test_email.deliver_later(:wait_until => slightly_earlier) + TestMailer.test_email.deliver_later(wait_until: slightly_earlier) }.to have_enqueued_email(TestMailer, :test_email).at(a_value_within(5.seconds).of(future)) end it "passes when deliver_later is called with a queue argument" do expect { - TestMailer.test_email.deliver_later(:queue => 'urgent_mail') + TestMailer.test_email.deliver_later(queue: 'urgent_mail') }.to have_enqueued_email(TestMailer, :test_email).on_queue('urgent_mail') end it "generates a failure message with on_queue" do expect { expect { - TestMailer.test_email.deliver_later(:queue => 'not_urgent_mail') + TestMailer.test_email.deliver_later(queue: 'not_urgent_mail') }.to have_enqueued_email(TestMailer, :test_email).on_queue('urgent_mail') }.to raise_error(/expected to enqueue TestMailer.test_email exactly 1 time on queue urgent_mail/) end @@ -295,7 +295,7 @@ def self.name; "NonMailerJob"; end expect { non_mailer_job.perform_later TestMailer.test_email.deliver_later - TestMailer.email_with_args(3, 4).deliver_later(:wait_until => send_time, :queue => queue) + TestMailer.email_with_args(3, 4).deliver_later(wait_until: send_time, queue: queue) }.to have_enqueued_email(TestMailer, :email_with_args).with(1, 2) }.to raise_error(message) end @@ -338,15 +338,15 @@ def self.name; "NonMailerJob"; end midnight = Date.tomorrow.midnight expect { - TestMailer.email_with_args('high', 'noon').deliver_later(:wait_until => noon) - TestMailer.email_with_args('midnight', 'rider').deliver_later(:wait_until => midnight) + TestMailer.email_with_args('high', 'noon').deliver_later(wait_until: noon) + TestMailer.email_with_args('midnight', 'rider').deliver_later(wait_until: midnight) }.to have_enqueued_mail(TestMailer, :email_with_args).at(noon).with { |first_arg, second_arg| expect(first_arg).to eq('high') expect(second_arg).to eq('noon') } end - context 'when parameterized', :skip => !RSpec::Rails::FeatureCheck.has_action_mailer_parameterized? do + context 'when parameterized', skip: !RSpec::Rails::FeatureCheck.has_action_mailer_parameterized? do it "passes when mailer is parameterized" do expect { TestMailer.with('foo' => 'bar').test_email.deliver_later @@ -371,7 +371,7 @@ def self.name; "NonMailerJob"; end end end - context 'mailer job is unified', :skip => !RSpec::Rails::FeatureCheck.has_action_mailer_unified_delivery? do + context 'mailer job is unified', skip: !RSpec::Rails::FeatureCheck.has_action_mailer_unified_delivery? do it "passes when mailer is parameterized" do expect { UnifiedMailer.with('foo' => 'bar').test_email.deliver_later @@ -389,13 +389,13 @@ def self.name; "NonMailerJob"; end expect { UnifiedMailer.with('foo' => 'bar').test_email.deliver_later }.to have_enqueued_mail(UnifiedMailer, :test_email).with( - a_hash_including(:params => { 'foo' => 'bar' }) + a_hash_including(params: { 'foo' => 'bar' }) ) expect { UnifiedMailer.with('foo' => 'bar').email_with_args(1, 2).deliver_later }.to have_enqueued_mail(UnifiedMailer, :email_with_args).with( - a_hash_including(:params => { 'foo' => 'bar' }, :args => [1, 2]) + a_hash_including(params: { 'foo' => 'bar' }, args: [1, 2]) ) end end