rspec-rails 4.0.0.beta3 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) 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 +5 -54
  5. data/Changelog.md +61 -7
  6. data/README.md +20 -19
  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_generator.rb +2 -2
  13. data/lib/generators/rspec/{generators → generator}/templates/generator_spec.rb +0 -0
  14. data/lib/generators/rspec/helper/helper_generator.rb +1 -1
  15. data/lib/generators/rspec/install/install_generator.rb +4 -4
  16. data/lib/generators/rspec/install/templates/spec/rails_helper.rb +17 -16
  17. data/lib/generators/rspec/integration/integration_generator.rb +3 -3
  18. data/lib/generators/rspec/mailer/mailer_generator.rb +1 -1
  19. data/lib/generators/rspec/model/model_generator.rb +4 -4
  20. data/lib/generators/rspec/scaffold/scaffold_generator.rb +26 -18
  21. data/lib/generators/rspec/scaffold/templates/api_controller_spec.rb +0 -36
  22. data/lib/generators/rspec/scaffold/templates/api_request_spec.rb +131 -0
  23. data/lib/generators/rspec/scaffold/templates/controller_spec.rb +10 -10
  24. data/lib/generators/rspec/scaffold/templates/edit_spec.rb +1 -1
  25. data/lib/generators/rspec/scaffold/templates/index_spec.rb +2 -2
  26. data/lib/generators/rspec/scaffold/templates/new_spec.rb +1 -1
  27. data/lib/generators/rspec/scaffold/templates/request_spec.rb +133 -0
  28. data/lib/generators/rspec/scaffold/templates/routing_spec.rb +8 -10
  29. data/lib/generators/rspec/scaffold/templates/show_spec.rb +1 -1
  30. data/lib/generators/rspec/system/system_generator.rb +1 -1
  31. data/lib/generators/rspec/view/view_generator.rb +2 -2
  32. data/lib/rspec-rails.rb +6 -9
  33. data/lib/rspec/rails/adapters.rb +10 -76
  34. data/lib/rspec/rails/configuration.rb +72 -36
  35. data/lib/rspec/rails/example/channel_example_group.rb +2 -2
  36. data/lib/rspec/rails/example/controller_example_group.rb +4 -4
  37. data/lib/rspec/rails/example/feature_example_group.rb +6 -26
  38. data/lib/rspec/rails/example/helper_example_group.rb +2 -10
  39. data/lib/rspec/rails/example/mailbox_example_group.rb +1 -1
  40. data/lib/rspec/rails/example/mailer_example_group.rb +2 -2
  41. data/lib/rspec/rails/example/rails_example_group.rb +1 -1
  42. data/lib/rspec/rails/example/system_example_group.rb +14 -7
  43. data/lib/rspec/rails/example/view_example_group.rb +38 -48
  44. data/lib/rspec/rails/extensions/active_record/proxy.rb +5 -10
  45. data/lib/rspec/rails/feature_check.rb +1 -28
  46. data/lib/rspec/rails/fixture_file_upload_support.rb +8 -13
  47. data/lib/rspec/rails/fixture_support.rb +37 -31
  48. data/lib/rspec/rails/matchers/action_cable.rb +1 -1
  49. data/lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb +3 -3
  50. data/lib/rspec/rails/matchers/active_job.rb +132 -18
  51. data/lib/rspec/rails/matchers/base_matcher.rb +4 -10
  52. data/lib/rspec/rails/matchers/have_enqueued_mail.rb +9 -6
  53. data/lib/rspec/rails/matchers/have_http_status.rb +7 -7
  54. data/lib/rspec/rails/matchers/relation_match_array.rb +1 -1
  55. data/lib/rspec/rails/matchers/routing_matchers.rb +11 -11
  56. data/lib/rspec/rails/tasks/rspec.rake +7 -17
  57. data/lib/rspec/rails/vendor/capybara.rb +10 -15
  58. data/lib/rspec/rails/version.rb +1 -1
  59. data/lib/rspec/rails/view_path_builder.rb +1 -1
  60. data/lib/rspec/rails/view_rendering.rb +3 -3
  61. metadata +34 -33
  62. metadata.gz.sig +0 -0
  63. data/lib/generators/rspec/observer/observer_generator.rb +0 -13
  64. data/lib/generators/rspec/observer/templates/observer_spec.rb +0 -7
@@ -7,9 +7,9 @@ module Rspec
7
7
  # Add a deprecation for this class, before rspec-rails 4, to use the
8
8
  # `RequestGenerator` instead
9
9
  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"
13
13
 
14
14
  def generate_request_spec
15
15
  return unless options[:request_specs]
@@ -5,7 +5,7 @@ module Rspec
5
5
  module Generators
6
6
  # @private
7
7
  class MailerGenerator < Base
8
- argument :actions, :type => :array, :default => [], :banner => "method method"
8
+ argument :actions, type: :array, default: [], banner: "method method"
9
9
 
10
10
  def generate_mailer_spec
11
11
  template "mailer_spec.rb", File.join('spec/mailers', class_path, "#{file_name}_spec.rb")
@@ -5,10 +5,10 @@ module Rspec
5
5
  # @private
6
6
  class ModelGenerator < Base
7
7
  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
12
12
 
13
13
  def create_model_spec
14
14
  template_file = File.join(
@@ -7,17 +7,18 @@ module Rspec
7
7
  class ScaffoldGenerator < Base
8
8
  include ::Rails::Generators::ResourceHelpers
9
9
  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"
11
11
 
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"
16
16
 
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: false, desc: "Generate controller specs"
18
+ class_option :request_specs, type: :boolean, default: true, desc: "Generate request specs"
19
+ class_option :view_specs, type: :boolean, default: true, desc: "Generate view specs"
20
+ class_option :helper_specs, type: :boolean, default: true, desc: "Generate helper specs"
21
+ class_option :routing_specs, type: :boolean, default: true, desc: "Generate routing specs"
21
22
 
22
23
  def initialize(*args, &blk)
23
24
  @generator_args = args.first
@@ -27,15 +28,20 @@ module Rspec
27
28
  def generate_controller_spec
28
29
  return unless options[:controller_specs]
29
30
 
30
- template_file = File.join(
31
- 'spec/controllers',
32
- controller_class_path,
33
- "#{controller_file_name}_controller_spec.rb"
34
- )
35
31
  if options[:api]
36
- template 'api_controller_spec.rb', template_file
32
+ template 'api_controller_spec.rb', template_file(folder: 'controllers', suffix: '_controller')
33
+ else
34
+ template 'controller_spec.rb', template_file(folder: 'controllers', suffix: '_controller')
35
+ end
36
+ end
37
+
38
+ def generate_request_spec
39
+ return unless options[:request_specs]
40
+
41
+ if options[:api]
42
+ template 'api_request_spec.rb', template_file(folder: 'requests')
37
43
  else
38
- template 'controller_spec.rb', template_file
44
+ template 'request_spec.rb', template_file(folder: 'requests')
39
45
  end
40
46
  end
41
47
 
@@ -60,8 +66,6 @@ module Rspec
60
66
  template 'routing_spec.rb', template_file
61
67
  end
62
68
 
63
- hook_for :integration_tool, :as => :integration
64
-
65
69
  protected
66
70
 
67
71
  attr_reader :generator_args
@@ -116,6 +120,10 @@ module Rspec
116
120
  end
117
121
  end
118
122
 
123
+ def template_file(folder:, suffix: '')
124
+ File.join('spec', folder, controller_class_path, "#{controller_file_name}#{suffix}_spec.rb")
125
+ end
126
+
119
127
  def banner
120
128
  self.class.banner
121
129
  end
@@ -46,11 +46,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
46
46
  describe "GET #index" do
47
47
  it "returns a success response" do
48
48
  <%= file_name %> = <%= class_name %>.create! valid_attributes
49
- <% if RUBY_VERSION < '1.9.3' -%>
50
- get :index, {}, valid_session
51
- <% else -%>
52
49
  get :index, params: {}, session: valid_session
53
- <% end -%>
54
50
  expect(response).to be_successful
55
51
  end
56
52
  end
@@ -59,11 +55,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
59
55
  describe "GET #show" do
60
56
  it "returns a success response" do
61
57
  <%= file_name %> = <%= class_name %>.create! valid_attributes
62
- <% if RUBY_VERSION < '1.9.3' -%>
63
- get :show, {:id => <%= file_name %>.to_param}, valid_session
64
- <% else -%>
65
58
  get :show, params: {id: <%= file_name %>.to_param}, session: valid_session
66
- <% end -%>
67
59
  expect(response).to be_successful
68
60
  end
69
61
  end
@@ -72,20 +64,12 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
72
64
  context "with valid params" do
73
65
  it "creates a new <%= class_name %>" do
74
66
  expect {
75
- <% if RUBY_VERSION < '1.9.3' -%>
76
- post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
77
- <% else -%>
78
67
  post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
79
- <% end -%>
80
68
  }.to change(<%= class_name %>, :count).by(1)
81
69
  end
82
70
 
83
71
  it "renders a JSON response with the new <%= ns_file_name %>" do
84
- <% if RUBY_VERSION < '1.9.3' -%>
85
- post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
86
- <% else %>
87
72
  post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
88
- <% end -%>
89
73
  expect(response).to have_http_status(:created)
90
74
  expect(response.content_type).to eq('application/json')
91
75
  expect(response.location).to eq(<%= ns_file_name %>_url(<%= class_name %>.last))
@@ -94,11 +78,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
94
78
 
95
79
  context "with invalid params" do
96
80
  it "renders a JSON response with errors for the new <%= ns_file_name %>" do
97
- <% if RUBY_VERSION < '1.9.3' -%>
98
- post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session
99
- <% else %>
100
81
  post :create, params: {<%= ns_file_name %>: invalid_attributes}, session: valid_session
101
- <% end -%>
102
82
  expect(response).to have_http_status(:unprocessable_entity)
103
83
  expect(response.content_type).to eq('application/json')
104
84
  end
@@ -113,22 +93,14 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
113
93
 
114
94
  it "updates the requested <%= ns_file_name %>" do
115
95
  <%= file_name %> = <%= class_name %>.create! valid_attributes
116
- <% if RUBY_VERSION < '1.9.3' -%>
117
- put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => new_attributes}, valid_session
118
- <% else -%>
119
96
  put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, session: valid_session
120
- <% end -%>
121
97
  <%= file_name %>.reload
122
98
  skip("Add assertions for updated state")
123
99
  end
124
100
 
125
101
  it "renders a JSON response with the <%= ns_file_name %>" do
126
102
  <%= file_name %> = <%= class_name %>.create! valid_attributes
127
- <% if RUBY_VERSION < '1.9.3' -%>
128
- put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
129
- <% else %>
130
103
  put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, session: valid_session
131
- <% end -%>
132
104
  expect(response).to have_http_status(:ok)
133
105
  expect(response.content_type).to eq('application/json')
134
106
  end
@@ -137,11 +109,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
137
109
  context "with invalid params" do
138
110
  it "renders a JSON response with errors for the <%= ns_file_name %>" do
139
111
  <%= file_name %> = <%= class_name %>.create! valid_attributes
140
- <% if RUBY_VERSION < '1.9.3' -%>
141
- put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
142
- <% else %>
143
112
  put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, session: valid_session
144
- <% end -%>
145
113
  expect(response).to have_http_status(:unprocessable_entity)
146
114
  expect(response.content_type).to eq('application/json')
147
115
  end
@@ -152,11 +120,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
152
120
  it "destroys the requested <%= ns_file_name %>" do
153
121
  <%= file_name %> = <%= class_name %>.create! valid_attributes
154
122
  expect {
155
- <% if RUBY_VERSION < '1.9.3' -%>
156
- delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
157
- <% else -%>
158
123
  delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session
159
- <% end -%>
160
124
  }.to change(<%= class_name %>, :count).by(-1)
161
125
  end
162
126
  end
@@ -0,0 +1,131 @@
1
+ require 'rails_helper'
2
+
3
+ # This spec was generated by rspec-rails when you ran the scaffold generator.
4
+ # It demonstrates how one might use RSpec to test the controller code that
5
+ # was generated by Rails when you ran the scaffold generator.
6
+ #
7
+ # It assumes that the implementation code is generated by the rails scaffold
8
+ # generator. If you are using any extension libraries to generate different
9
+ # controller code, this generated spec may or may not pass.
10
+ #
11
+ # It only uses APIs available in rails and/or rspec-rails. There are a number
12
+ # of tools you can use to make these specs even more expressive, but we're
13
+ # sticking to rails and rspec-rails APIs to keep things simple and stable.
14
+
15
+ <% module_namespacing do -%>
16
+ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %> do
17
+ # This should return the minimal set of attributes required to create a valid
18
+ # <%= class_name %>. As you add validations to <%= class_name %>, be sure to
19
+ # adjust the attributes here as well.
20
+ let(:valid_attributes) {
21
+ skip("Add a hash of attributes valid for your model")
22
+ }
23
+
24
+ let(:invalid_attributes) {
25
+ skip("Add a hash of attributes invalid for your model")
26
+ }
27
+
28
+ # This should return the minimal set of values that should be in the headers
29
+ # in order to pass any filters (e.g. authentication) defined in
30
+ # <%= controller_class_name %>Controller, or in your router and rack
31
+ # middleware. Be sure to keep this updated too.
32
+ let(:valid_headers) {
33
+ {}
34
+ }
35
+
36
+ <% unless options[:singleton] -%>
37
+ describe "GET /index" do
38
+ it "renders a successful response" do
39
+ <%= class_name %>.create! valid_attributes
40
+ get <%= index_helper %>_url, headers: valid_headers, as: :json
41
+ expect(response).to be_successful
42
+ end
43
+ end
44
+ <% end -%>
45
+
46
+ describe "GET /show" do
47
+ it "renders a successful response" do
48
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
49
+ get <%= show_helper.tr('@', '') %>, as: :json
50
+ expect(response).to be_successful
51
+ end
52
+ end
53
+
54
+ describe "POST /create" do
55
+ context "with valid parameters" do
56
+ it "creates a new <%= class_name %>" do
57
+ expect {
58
+ post <%= index_helper %>_url,
59
+ params: { <%= ns_file_name %>: valid_attributes }, headers: valid_headers, as: :json
60
+ }.to change(<%= class_name %>, :count).by(1)
61
+ end
62
+
63
+ it "renders a JSON response with the new <%= ns_file_name %>" do
64
+ post <%= index_helper %>_url,
65
+ params: { <%= ns_file_name %>: valid_attributes }, headers: valid_headers, as: :json
66
+ expect(response).to have_http_status(:created)
67
+ expect(response.content_type).to match(a_string_including("application/json"))
68
+ end
69
+ end
70
+
71
+ context "with invalid parameters" do
72
+ it "does not create a new <%= class_name %>" do
73
+ expect {
74
+ post <%= index_helper %>_url,
75
+ params: { <%= ns_file_name %>: invalid_attributes }, as: :json
76
+ }.to change(<%= class_name %>, :count).by(0)
77
+ end
78
+
79
+ it "renders a JSON response with errors for the new <%= ns_file_name %>" do
80
+ post <%= index_helper %>_url,
81
+ params: { <%= ns_file_name %>: invalid_attributes }, headers: valid_headers, as: :json
82
+ expect(response).to have_http_status(:unprocessable_entity)
83
+ expect(response.content_type).to eq("application/json")
84
+ end
85
+ end
86
+ end
87
+
88
+ describe "PATCH /update" do
89
+ context "with valid parameters" do
90
+ let(:new_attributes) {
91
+ skip("Add a hash of attributes valid for your model")
92
+ }
93
+
94
+ it "updates the requested <%= ns_file_name %>" do
95
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
96
+ patch <%= show_helper.tr('@', '') %>,
97
+ params: { <%= singular_table_name %>: new_attributes }, headers: valid_headers, as: :json
98
+ <%= file_name %>.reload
99
+ skip("Add assertions for updated state")
100
+ end
101
+
102
+ it "renders a JSON response with the <%= ns_file_name %>" do
103
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
104
+ patch <%= show_helper.tr('@', '') %>,
105
+ params: { <%= singular_table_name %>: new_attributes }, headers: valid_headers, as: :json
106
+ expect(response).to have_http_status(:ok)
107
+ expect(response.content_type).to match(a_string_including("application/json"))
108
+ end
109
+ end
110
+
111
+ context "with invalid parameters" do
112
+ it "renders a JSON response with errors for the <%= ns_file_name %>" do
113
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
114
+ patch <%= show_helper.tr('@', '') %>,
115
+ params: { <%= singular_table_name %>: invalid_attributes }, headers: valid_headers, as: :json
116
+ expect(response).to have_http_status(:unprocessable_entity)
117
+ expect(response.content_type).to eq("application/json")
118
+ end
119
+ end
120
+ end
121
+
122
+ describe "DELETE /destroy" do
123
+ it "destroys the requested <%= ns_file_name %>" do
124
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
125
+ expect {
126
+ delete <%= show_helper.tr('@', '') %>, headers: valid_headers, as: :json
127
+ }.to change(<%= class_name %>, :count).by(-1)
128
+ end
129
+ end
130
+ end
131
+ <% end -%>
@@ -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