rspec-rails 4.0.0.beta3 → 4.0.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/Capybara.md +1 -1
  5. data/Changelog.md +48 -12
  6. data/README.md +3 -4
  7. data/lib/generators/rspec.rb +0 -6
  8. data/lib/generators/rspec/controller/controller_generator.rb +13 -5
  9. data/lib/generators/rspec/controller/templates/request_spec.rb +14 -0
  10. data/lib/generators/rspec/controller/templates/routing_spec.rb +1 -1
  11. data/lib/generators/rspec/feature/feature_generator.rb +2 -2
  12. data/lib/generators/rspec/generators/generator_generator.rb +1 -1
  13. data/lib/generators/rspec/helper/helper_generator.rb +1 -1
  14. data/lib/generators/rspec/install/install_generator.rb +4 -4
  15. data/lib/generators/rspec/install/templates/spec/rails_helper.rb +2 -15
  16. data/lib/generators/rspec/integration/integration_generator.rb +3 -3
  17. data/lib/generators/rspec/mailer/mailer_generator.rb +1 -1
  18. data/lib/generators/rspec/model/model_generator.rb +4 -4
  19. data/lib/generators/rspec/scaffold/scaffold_generator.rb +10 -10
  20. data/lib/generators/rspec/scaffold/templates/api_controller_spec.rb +0 -36
  21. data/lib/generators/rspec/scaffold/templates/controller_spec.rb +10 -10
  22. data/lib/generators/rspec/scaffold/templates/edit_spec.rb +1 -1
  23. data/lib/generators/rspec/scaffold/templates/index_spec.rb +2 -2
  24. data/lib/generators/rspec/scaffold/templates/new_spec.rb +1 -1
  25. data/lib/generators/rspec/scaffold/templates/routing_spec.rb +8 -10
  26. data/lib/generators/rspec/scaffold/templates/show_spec.rb +1 -1
  27. data/lib/generators/rspec/system/system_generator.rb +1 -1
  28. data/lib/generators/rspec/view/view_generator.rb +2 -2
  29. data/lib/rspec-rails.rb +4 -7
  30. data/lib/rspec/rails/adapters.rb +8 -74
  31. data/lib/rspec/rails/configuration.rb +32 -32
  32. data/lib/rspec/rails/example/controller_example_group.rb +4 -4
  33. data/lib/rspec/rails/example/feature_example_group.rb +5 -7
  34. data/lib/rspec/rails/example/helper_example_group.rb +2 -10
  35. data/lib/rspec/rails/example/rails_example_group.rb +1 -1
  36. data/lib/rspec/rails/example/system_example_group.rb +6 -3
  37. data/lib/rspec/rails/example/view_example_group.rb +38 -48
  38. data/lib/rspec/rails/extensions/active_record/proxy.rb +1 -9
  39. data/lib/rspec/rails/feature_check.rb +1 -28
  40. data/lib/rspec/rails/fixture_file_upload_support.rb +1 -1
  41. data/lib/rspec/rails/fixture_support.rb +8 -13
  42. data/lib/rspec/rails/matchers/action_cable.rb +1 -1
  43. data/lib/rspec/rails/matchers/active_job.rb +124 -14
  44. data/lib/rspec/rails/matchers/base_matcher.rb +4 -10
  45. data/lib/rspec/rails/matchers/have_enqueued_mail.rb +5 -2
  46. data/lib/rspec/rails/matchers/have_http_status.rb +7 -7
  47. data/lib/rspec/rails/matchers/routing_matchers.rb +10 -10
  48. data/lib/rspec/rails/tasks/rspec.rake +3 -13
  49. data/lib/rspec/rails/vendor/capybara.rb +10 -10
  50. data/lib/rspec/rails/version.rb +1 -1
  51. data/lib/rspec/rails/view_path_builder.rb +1 -1
  52. data/lib/rspec/rails/view_rendering.rb +3 -3
  53. metadata +16 -17
  54. metadata.gz.sig +0 -0
  55. data/lib/generators/rspec/observer/observer_generator.rb +0 -13
  56. data/lib/generators/rspec/observer/templates/observer_spec.rb +0 -7
@@ -60,7 +60,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
60
60
  it "returns a success response" do
61
61
  <%= file_name %> = <%= class_name %>.create! valid_attributes
62
62
  <% if Rails::VERSION::STRING < '5.0' -%>
63
- get :show, {:id => <%= file_name %>.to_param}, valid_session
63
+ get :show, {id: <%= file_name %>.to_param}, valid_session
64
64
  <% else -%>
65
65
  get :show, params: {id: <%= file_name %>.to_param}, session: valid_session
66
66
  <% end -%>
@@ -83,7 +83,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
83
83
  it "returns a success response" do
84
84
  <%= file_name %> = <%= class_name %>.create! valid_attributes
85
85
  <% if Rails::VERSION::STRING < '5.0' -%>
86
- get :edit, {:id => <%= file_name %>.to_param}, valid_session
86
+ get :edit, {id: <%= file_name %>.to_param}, valid_session
87
87
  <% else -%>
88
88
  get :edit, params: {id: <%= file_name %>.to_param}, session: valid_session
89
89
  <% end -%>
@@ -96,7 +96,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
96
96
  it "creates a new <%= class_name %>" do
97
97
  expect {
98
98
  <% if Rails::VERSION::STRING < '5.0' -%>
99
- post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
99
+ post :create, {<%= ns_file_name %>: valid_attributes}, valid_session
100
100
  <% else -%>
101
101
  post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
102
102
  <% end -%>
@@ -105,7 +105,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
105
105
 
106
106
  it "redirects to the created <%= ns_file_name %>" do
107
107
  <% if Rails::VERSION::STRING < '5.0' -%>
108
- post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
108
+ post :create, {<%= ns_file_name %>: valid_attributes}, valid_session
109
109
  <% else -%>
110
110
  post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
111
111
  <% end -%>
@@ -116,7 +116,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
116
116
  context "with invalid params" do
117
117
  it "returns a success response (i.e. to display the 'new' template)" do
118
118
  <% if Rails::VERSION::STRING < '5.0' -%>
119
- post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session
119
+ post :create, {<%= ns_file_name %>: invalid_attributes}, valid_session
120
120
  <% else -%>
121
121
  post :create, params: {<%= ns_file_name %>: invalid_attributes}, session: valid_session
122
122
  <% end -%>
@@ -134,7 +134,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
134
134
  it "updates the requested <%= ns_file_name %>" do
135
135
  <%= file_name %> = <%= class_name %>.create! valid_attributes
136
136
  <% if Rails::VERSION::STRING < '5.0' -%>
137
- put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => new_attributes}, valid_session
137
+ put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, valid_session
138
138
  <% else -%>
139
139
  put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, session: valid_session
140
140
  <% end -%>
@@ -145,7 +145,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
145
145
  it "redirects to the <%= ns_file_name %>" do
146
146
  <%= file_name %> = <%= class_name %>.create! valid_attributes
147
147
  <% if Rails::VERSION::STRING < '5.0' -%>
148
- put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
148
+ put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, valid_session
149
149
  <% else -%>
150
150
  put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, session: valid_session
151
151
  <% end -%>
@@ -157,7 +157,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
157
157
  it "returns a success response (i.e. to display the 'edit' template)" do
158
158
  <%= file_name %> = <%= class_name %>.create! valid_attributes
159
159
  <% if Rails::VERSION::STRING < '5.0' -%>
160
- put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
160
+ put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, valid_session
161
161
  <% else -%>
162
162
  put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, session: valid_session
163
163
  <% end -%>
@@ -171,7 +171,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
171
171
  <%= file_name %> = <%= class_name %>.create! valid_attributes
172
172
  expect {
173
173
  <% if Rails::VERSION::STRING < '5.0' -%>
174
- delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
174
+ delete :destroy, {id: <%= file_name %>.to_param}, valid_session
175
175
  <% else -%>
176
176
  delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session
177
177
  <% end -%>
@@ -181,7 +181,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
181
181
  it "redirects to the <%= table_name %> list" do
182
182
  <%= file_name %> = <%= class_name %>.create! valid_attributes
183
183
  <% if Rails::VERSION::STRING < '5.0' -%>
184
- delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
184
+ delete :destroy, {id: <%= file_name %>.to_param}, valid_session
185
185
  <% else -%>
186
186
  delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session
187
187
  <% end -%>
@@ -5,7 +5,7 @@ RSpec.describe "<%= ns_table_name %>/edit", <%= type_metatag(:view) %> do
5
5
  before(:each) do
6
6
  @<%= ns_file_name %> = assign(:<%= ns_file_name %>, <%= class_name %>.create!(<%= '))' if output_attributes.empty? %>
7
7
  <% output_attributes.each_with_index do |attribute, attribute_index| -%>
8
- :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
8
+ <%= attribute.name %>: <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
9
9
  <% end -%>
10
10
  <%= output_attributes.empty? ? "" : " ))\n" -%>
11
11
  end
@@ -7,7 +7,7 @@ RSpec.describe "<%= ns_table_name %>/index", <%= type_metatag(:view) %> do
7
7
  <% [1,2].each_with_index do |id, model_index| -%>
8
8
  <%= class_name %>.create!(<%= output_attributes.empty? ? (model_index == 1 ? ')' : '),') : '' %>
9
9
  <% output_attributes.each_with_index do |attribute, attribute_index| -%>
10
- :<%= attribute.name %> => <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
10
+ <%= attribute.name %>: <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
11
11
  <% end -%>
12
12
  <% if !output_attributes.empty? -%>
13
13
  <%= model_index == 1 ? ')' : '),' %>
@@ -19,7 +19,7 @@ RSpec.describe "<%= ns_table_name %>/index", <%= type_metatag(:view) %> do
19
19
  it "renders a list of <%= ns_table_name %>" do
20
20
  render
21
21
  <% for attribute in output_attributes -%>
22
- assert_select "tr>td", :text => <%= value_for(attribute) %>.to_s, :count => 2
22
+ assert_select "tr>td", text: <%= value_for(attribute) %>.to_s, count: 2
23
23
  <% end -%>
24
24
  end
25
25
  end
@@ -5,7 +5,7 @@ RSpec.describe "<%= ns_table_name %>/new", <%= type_metatag(:view) %> do
5
5
  before(:each) do
6
6
  assign(:<%= ns_file_name %>, <%= class_name %>.new(<%= '))' if output_attributes.empty? %>
7
7
  <% output_attributes.each_with_index do |attribute, attribute_index| -%>
8
- :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
8
+ <%= attribute.name %>: <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
9
9
  <% end -%>
10
10
  <%= !output_attributes.empty? ? " ))\n end" : " end" %>
11
11
 
@@ -5,43 +5,41 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:routing
5
5
  describe "routing" do
6
6
  <% unless options[:singleton] -%>
7
7
  it "routes to #index" do
8
- expect(:get => "/<%= ns_table_name %>").to route_to("<%= ns_table_name %>#index")
8
+ expect(get: "/<%= ns_table_name %>").to route_to("<%= ns_table_name %>#index")
9
9
  end
10
10
 
11
11
  <% end -%>
12
12
  <% unless options[:api] -%>
13
13
  it "routes to #new" do
14
- expect(:get => "/<%= ns_table_name %>/new").to route_to("<%= ns_table_name %>#new")
14
+ expect(get: "/<%= ns_table_name %>/new").to route_to("<%= ns_table_name %>#new")
15
15
  end
16
16
 
17
17
  <% end -%>
18
18
  it "routes to #show" do
19
- expect(:get => "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#show", :id => "1")
19
+ expect(get: "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#show", id: "1")
20
20
  end
21
21
 
22
22
  <% unless options[:api] -%>
23
23
  it "routes to #edit" do
24
- expect(:get => "/<%= ns_table_name %>/1/edit").to route_to("<%= ns_table_name %>#edit", :id => "1")
24
+ expect(get: "/<%= ns_table_name %>/1/edit").to route_to("<%= ns_table_name %>#edit", id: "1")
25
25
  end
26
26
 
27
27
  <% end -%>
28
28
 
29
29
  it "routes to #create" do
30
- expect(:post => "/<%= ns_table_name %>").to route_to("<%= ns_table_name %>#create")
30
+ expect(post: "/<%= ns_table_name %>").to route_to("<%= ns_table_name %>#create")
31
31
  end
32
32
 
33
33
  it "routes to #update via PUT" do
34
- expect(:put => "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#update", :id => "1")
34
+ expect(put: "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#update", id: "1")
35
35
  end
36
36
 
37
- <% if Rails::VERSION::STRING > '4' -%>
38
37
  it "routes to #update via PATCH" do
39
- expect(:patch => "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#update", :id => "1")
38
+ expect(patch: "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#update", id: "1")
40
39
  end
41
40
 
42
- <% end -%>
43
41
  it "routes to #destroy" do
44
- expect(:delete => "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#destroy", :id => "1")
42
+ expect(delete: "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#destroy", id: "1")
45
43
  end
46
44
  end
47
45
  end
@@ -5,7 +5,7 @@ RSpec.describe "<%= ns_table_name %>/show", <%= type_metatag(:view) %> do
5
5
  before(:each) do
6
6
  @<%= ns_file_name %> = assign(:<%= ns_file_name %>, <%= class_name %>.create!(<%= '))' if output_attributes.empty? %>
7
7
  <% output_attributes.each_with_index do |attribute, attribute_index| -%>
8
- :<%= attribute.name %> => <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
8
+ <%= attribute.name %>: <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
9
9
  <% end -%>
10
10
  <% if !output_attributes.empty? -%>
11
11
  ))
@@ -5,7 +5,7 @@ if ::Rails::VERSION::STRING >= '5.1'
5
5
  module Generators
6
6
  # @private
7
7
  class SystemGenerator < Base
8
- class_option :system_specs, :type => :boolean, :default => true, :desc => "Generate system specs"
8
+ class_option :system_specs, type: :boolean, default: true, desc: "Generate system specs"
9
9
 
10
10
  def generate_system_spec
11
11
  return unless options[:system_specs]
@@ -4,9 +4,9 @@ module Rspec
4
4
  module Generators
5
5
  # @private
6
6
  class ViewGenerator < Base
7
- argument :actions, :type => :array, :default => [], :banner => "action action"
7
+ argument :actions, type: :array, default: [], banner: "action action"
8
8
 
9
- class_option :template_engine, :desc => "Template engine to generate view files"
9
+ class_option :template_engine, desc: "Template engine to generate view files"
10
10
 
11
11
  def create_view_specs
12
12
  empty_directory File.join("spec", "views", file_path)
@@ -15,8 +15,7 @@ module RSpec
15
15
  SourceAnnotationExtractor::Annotation.register_directories("spec")
16
16
  end
17
17
  end
18
- # Rails-3.0.1 requires config.app_generators instead of 3.0.0's config.generators
19
- generators = config.respond_to?(:app_generators) ? config.app_generators : config.generators
18
+ generators = config.app_generators
20
19
  generators.integration_tool :rspec
21
20
  generators.test_framework :rspec
22
21
 
@@ -31,7 +30,7 @@ module RSpec
31
30
  # This is called after the environment has been loaded but before Rails
32
31
  # sets the default for the `preview_path`
33
32
  initializer "rspec_rails.action_mailer",
34
- :before => "action_mailer.set_configs" do |app|
33
+ before: "action_mailer.set_configs" do |app|
35
34
  setup_preview_path(app)
36
35
  end
37
36
 
@@ -47,9 +46,7 @@ module RSpec
47
46
  def config_preview_path?(options)
48
47
  # We cannot use `respond_to?(:show_previews)` here as it will always
49
48
  # return `true`.
50
- if ::Rails::VERSION::STRING < '4.2'
51
- ::Rails.env.development?
52
- elsif options.show_previews.nil?
49
+ if options.show_previews.nil?
53
50
  options.show_previews = ::Rails.env.development?
54
51
  else
55
52
  options.show_previews
@@ -74,7 +71,7 @@ module RSpec
74
71
  # not respond to the method. However, we cannot use
75
72
  # `config.action_mailer.respond_to?(:preview_path)` here as it will
76
73
  # always return `true`.
77
- config.respond_to?(:action_mailer) && ::Rails::VERSION::STRING > '4.1'
74
+ config.respond_to?(:action_mailer)
78
75
  end
79
76
  end
80
77
  end
@@ -19,68 +19,15 @@ module RSpec
19
19
  end
20
20
  private_class_method :disable_testunit_autorun
21
21
 
22
- if ::Rails::VERSION::STRING >= '4.1.0'
23
- if defined?(Kernel.gem)
24
- gem 'minitest'
25
- else
26
- require 'minitest'
27
- end
28
- require 'minitest/assertions'
29
- # Constant aliased to either Minitest or TestUnit, depending on what is
30
- # loaded.
31
- Assertions = Minitest::Assertions
32
- elsif RUBY_VERSION >= '2.2.0'
33
- # Minitest / TestUnit has been removed from ruby core. However, we are
34
- # on an old Rails version and must load the appropriate gem
35
- if ::Rails::VERSION::STRING >= '4.0.0'
36
- # ActiveSupport 4.0.x has the minitest '~> 4.2' gem as a dependency
37
- # This gem has no `lib/minitest.rb` file.
38
- gem 'minitest' if defined?(Kernel.gem)
39
- require 'minitest/unit'
40
- Assertions = MiniTest::Assertions
41
- elsif ::Rails::VERSION::STRING >= '3.2.21'
42
- # TODO: Change the above check to >= '3.2.22' once it's released
43
- begin
44
- # Test::Unit "helpfully" sets up autoload for its `AutoRunner`.
45
- # While we do not reference it directly, when we load the `TestCase`
46
- # classes from AS (ActiveSupport), AS kindly references `AutoRunner`
47
- # for everyone.
48
- #
49
- # To handle this we need to pre-emptively load 'test/unit' and make
50
- # sure the version installed has `AutoRunner` (the 3.x line does to
51
- # date). If so, we turn the auto runner off.
52
- require 'test/unit'
53
- require 'test/unit/assertions'
54
- disable_testunit_autorun
55
- rescue LoadError => e
56
- raise LoadError, <<-ERR.squish, e.backtrace
57
- Ruby 2.2+ has removed test/unit from the core library. Rails
58
- requires this as a dependency. Please add test-unit gem to your
59
- Gemfile: `gem 'test-unit', '~> 3.0'` (#{e.message})"
60
- ERR
61
- end
62
- Assertions = Test::Unit::Assertions
63
- else
64
- abort <<-MSG.squish
65
- Ruby 2.2+ is not supported on Rails #{::Rails::VERSION::STRING}.
66
- Check the Rails release notes for the appropriate update with
67
- support.
68
- MSG
69
- end
22
+ if defined?(Kernel.gem)
23
+ gem 'minitest'
70
24
  else
71
- begin
72
- require 'test/unit/assertions'
73
- rescue LoadError
74
- # work around for Rubinius not having a std std-lib
75
- require 'rubysl-test-unit' if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
76
- require 'test/unit/assertions'
77
- end
78
- # Turn off test unit's auto runner for those using the gem
79
- disable_testunit_autorun
80
- # Constant aliased to either Minitest or TestUnit, depending on what is
81
- # loaded.
82
- Assertions = Test::Unit::Assertions
25
+ require 'minitest'
83
26
  end
27
+ require 'minitest/assertions'
28
+ # Constant aliased to either Minitest or TestUnit, depending on what is
29
+ # loaded.
30
+ Assertions = Minitest::Assertions
84
31
 
85
32
  # @private
86
33
  class AssertionDelegator < Module
@@ -199,12 +146,11 @@ module RSpec
199
146
  # examples without exposing non-assertion methods in Test::Unit or
200
147
  # Minitest.
201
148
  def assertion_method_names
202
- methods = ::RSpec::Rails::Assertions.
149
+ ::RSpec::Rails::Assertions.
203
150
  public_instance_methods.
204
151
  select do |m|
205
152
  m.to_s =~ /^(assert|flunk|refute)/
206
153
  end
207
- methods + test_unit_specific_methods
208
154
  end
209
155
 
210
156
  def define_assertion_delegators
@@ -214,18 +160,6 @@ module RSpec
214
160
  end
215
161
  end
216
162
  end
217
-
218
- # Starting on Rails 4, Minitest is the default testing framework so no
219
- # need to add TestUnit specific methods.
220
- if ::Rails::VERSION::STRING >= '4.0.0'
221
- def test_unit_specific_methods
222
- []
223
- end
224
- else
225
- def test_unit_specific_methods
226
- [:build_message]
227
- end
228
- end
229
163
  end
230
164
 
231
165
  class AssertionDelegator
@@ -25,33 +25,33 @@ module RSpec
25
25
  #
26
26
  # @api private
27
27
  DIRECTORY_MAPPINGS = {
28
- :channel => %w[spec channels],
29
- :controller => %w[spec controllers],
30
- :helper => %w[spec helpers],
31
- :job => %w[spec jobs],
32
- :mailer => %w[spec mailers],
33
- :model => %w[spec models],
34
- :request => %w[spec (requests|integration|api)],
35
- :routing => %w[spec routing],
36
- :view => %w[spec views],
37
- :feature => %w[spec features],
38
- :system => %w[spec system],
39
- :mailbox => %w[spec mailboxes]
28
+ channel: %w[spec channels],
29
+ controller: %w[spec controllers],
30
+ helper: %w[spec helpers],
31
+ job: %w[spec jobs],
32
+ mailer: %w[spec mailers],
33
+ model: %w[spec models],
34
+ request: %w[spec (requests|integration|api)],
35
+ routing: %w[spec routing],
36
+ view: %w[spec views],
37
+ feature: %w[spec features],
38
+ system: %w[spec system],
39
+ mailbox: %w[spec mailboxes]
40
40
  }
41
41
 
42
42
  # Sets up the different example group modules for the different spec types
43
43
  #
44
44
  # @api private
45
45
  def self.add_test_type_configurations(config)
46
- config.include RSpec::Rails::ControllerExampleGroup, :type => :controller
47
- config.include RSpec::Rails::HelperExampleGroup, :type => :helper
48
- config.include RSpec::Rails::ModelExampleGroup, :type => :model
49
- config.include RSpec::Rails::RequestExampleGroup, :type => :request
50
- config.include RSpec::Rails::RoutingExampleGroup, :type => :routing
51
- config.include RSpec::Rails::ViewExampleGroup, :type => :view
52
- config.include RSpec::Rails::FeatureExampleGroup, :type => :feature
46
+ config.include RSpec::Rails::ControllerExampleGroup, type: :controller
47
+ config.include RSpec::Rails::HelperExampleGroup, type: :helper
48
+ config.include RSpec::Rails::ModelExampleGroup, type: :model
49
+ config.include RSpec::Rails::RequestExampleGroup, type: :request
50
+ config.include RSpec::Rails::RoutingExampleGroup, type: :routing
51
+ config.include RSpec::Rails::ViewExampleGroup, type: :view
52
+ config.include RSpec::Rails::FeatureExampleGroup, type: :feature
53
53
  config.include RSpec::Rails::Matchers
54
- config.include RSpec::Rails::SystemExampleGroup, :type => :system
54
+ config.include RSpec::Rails::SystemExampleGroup, type: :system
55
55
  end
56
56
 
57
57
  # @private
@@ -61,10 +61,10 @@ module RSpec
61
61
  config.backtrace_exclusion_patterns << %r{lib/rspec/rails}
62
62
 
63
63
  # controller settings
64
- config.add_setting :infer_base_class_for_anonymous_controllers, :default => true
64
+ config.add_setting :infer_base_class_for_anonymous_controllers, default: true
65
65
 
66
66
  # fixture support
67
- config.add_setting :use_transactional_fixtures, :alias_with => :use_transactional_examples
67
+ config.add_setting :use_transactional_fixtures, alias_with: :use_transactional_examples
68
68
  config.add_setting :use_instantiated_fixtures
69
69
  config.add_setting :global_fixtures
70
70
  config.add_setting :fixture_path
@@ -80,7 +80,7 @@ module RSpec
80
80
  config.include RSpec::Rails::FixtureSupport
81
81
 
82
82
  if ::Rails::VERSION::STRING > '5'
83
- config.add_setting :file_fixture_path, :default => 'spec/fixtures/files'
83
+ config.add_setting :file_fixture_path, default: 'spec/fixtures/files'
84
84
  config.include RSpec::Rails::FileFixtureSupport
85
85
  end
86
86
 
@@ -93,7 +93,7 @@ module RSpec
93
93
  # as a getter. This makes it easier for rspec-rails users because we use
94
94
  # `render_views` directly in example groups, so this aligns the two APIs,
95
95
  # but requires this workaround:
96
- config.add_setting :rendering_views, :default => false
96
+ config.add_setting :rendering_views, default: false
97
97
 
98
98
  config.instance_exec do
99
99
  def render_views=(val)
@@ -111,7 +111,7 @@ module RSpec
111
111
  def infer_spec_type_from_file_location!
112
112
  DIRECTORY_MAPPINGS.each do |type, dir_parts|
113
113
  escaped_path = Regexp.compile(dir_parts.join('[\\\/]') + '[\\\/]')
114
- define_derived_metadata(:file_path => escaped_path) do |metadata|
114
+ define_derived_metadata(file_path: escaped_path) do |metadata|
115
115
  metadata[:type] ||= type
116
116
  end
117
117
  end
@@ -129,26 +129,26 @@ module RSpec
129
129
 
130
130
  if defined?(::Rails::Controller::Testing)
131
131
  [:controller, :view, :request].each do |type|
132
- config.include ::Rails::Controller::Testing::TestProcess, :type => type
133
- config.include ::Rails::Controller::Testing::TemplateAssertions, :type => type
134
- config.include ::Rails::Controller::Testing::Integration, :type => type
132
+ config.include ::Rails::Controller::Testing::TestProcess, type: type
133
+ config.include ::Rails::Controller::Testing::TemplateAssertions, type: type
134
+ config.include ::Rails::Controller::Testing::Integration, type: type
135
135
  end
136
136
  end
137
137
 
138
138
  if RSpec::Rails::FeatureCheck.has_action_mailer?
139
- config.include RSpec::Rails::MailerExampleGroup, :type => :mailer
139
+ config.include RSpec::Rails::MailerExampleGroup, type: :mailer
140
140
  end
141
141
 
142
142
  if RSpec::Rails::FeatureCheck.has_active_job?
143
- config.include RSpec::Rails::JobExampleGroup, :type => :job
143
+ config.include RSpec::Rails::JobExampleGroup, type: :job
144
144
  end
145
145
 
146
146
  if RSpec::Rails::FeatureCheck.has_action_cable_testing?
147
- config.include RSpec::Rails::ChannelExampleGroup, :type => :channel
147
+ config.include RSpec::Rails::ChannelExampleGroup, type: :channel
148
148
  end
149
149
 
150
150
  if RSpec::Rails::FeatureCheck.has_action_mailbox?
151
- config.include RSpec::Rails::MailboxExampleGroup, :type => :mailbox
151
+ config.include RSpec::Rails::MailboxExampleGroup, type: :mailbox
152
152
  end
153
153
  end
154
154
  # rubocop:enable Metrics/MethodLength