rspec_rails_scaffold_templates 3.2.1 → 3.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b12b321c6dbfe9e69343dffd621425e8b59dd4732bd2bce9f24b5c35e398a3d
4
- data.tar.gz: 534284aff760071514d6252c7a60045a0585bb21cb7e5456f14cf2ca9db41bfc
3
+ metadata.gz: 66e7251a0586b2006eaf26b437784fbf9d81b2dabe740bbcd47f652bdcb5ab9f
4
+ data.tar.gz: c288e0df93ee5c099d875ad76a7c5073acb081ab1077d2e57b1004e749def2c6
5
5
  SHA512:
6
- metadata.gz: d41c553c157a44a33baa6c9707ec05491e00110d6a3b8c6a5445a2e679ad88e93672ad1d69f28b15e53d645774d84247ec55a24fcff850ef76e88d887ac9cb37
7
- data.tar.gz: 7d50a685719c41ac97b04796771d69189eb7de6c5bb95e5f54c49252ee2d51ec260d0377450c467d5da37fb8c0751e5595a6cedb5682d249c1b0eadfc00bc350
6
+ metadata.gz: 50618b1893d5381b6959072d49fe2ab4fba2cec12a78c329344ea344fdaeba14d2522e78e54d39f2be1ad95a65c6ef59cacebf12f9f976be1ea8b5c4df65c1a6
7
+ data.tar.gz: 110a14299902c63b9c5501af2a59180ef07c423600174784d1cef26693fd2f862c474c1a27981b4f4da9a6bd70f57995e8474113b15f9b504e9acdf87bf8449f
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ source "http://rubygems.org"
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
9
  gem "rspec", "~> 3.1"
10
- gem "rdoc", "~> 4.1"
10
+ gem "rdoc", "~> 6.1"
11
11
  gem "bundler", "~> 2.3.9"
12
12
  gem "jeweler", "~> 2.0"
13
13
  gem "simplecov", "~> 0.0"
data/Rakefile CHANGED
@@ -19,8 +19,8 @@ Jeweler::Tasks.new do |gem|
19
19
  gem.license = "MIT"
20
20
  gem.summary = %Q{RSpec scaffold generator templates that use FactoryGirl and WiceGrid}
21
21
  gem.description = %Q{RSpec scaffold generator templates that use FactoryGirl and WiceGrid}
22
- gem.email = "dima@koulikoff.de"
23
- gem.authors = ["Dmitri Koulikoff"]
22
+ gem.email = "dimitri@kulk.eu"
23
+ gem.authors = ["Dimitri Kulk"]
24
24
  gem.version = File.exist?('VERSION') ? File.read('VERSION') : ""
25
25
  # dependencies defined in Gemfile
26
26
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.1
1
+ 3.3.0
@@ -0,0 +1,220 @@
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
+ describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %> do
17
+ <% if method = Rails.application.config.generators.options[:rails][:cancan] -%>
18
+ <% method = 'current_user' unless Symbol === method -%>
19
+ before :each do
20
+ allow_any_instance_of(<%= controller_class_name %>Controller).to receive(:<%=method%>)
21
+ .and_return(<%=method%>)
22
+ <% if options[:cancan] -%>
23
+ allow_any_instance_of(Ability).to receive(:can?).and_return true
24
+ <% end -%>
25
+ end
26
+
27
+ <% end -%>
28
+ # This should return the minimal set of attributes required to create a valid
29
+ # <%= class_name %>. As you add validations to <%= class_name %>, be sure to
30
+ # adjust the attributes here as well. The list could not be empty.
31
+ <% links = attributes.select{|a| [:belongs_to, :references].include? a.type} -%>
32
+ <% attribute = (attributes - links).detect{|a| a.name == 'name' || a.name == 'title' || a.name == 'code' || a.name =~ /name/ || a.name =~ /title/} || attributes.first -%>
33
+ <% attribute_name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name -%>
34
+ <% if Rails.application.config.generators.options[:rails][:fixture_replacement] == :factory_bot -%>
35
+ <% factory_bot = true -%>
36
+ let(:<%= file_name %>) {create :<%= file_name %>}
37
+
38
+ <% if links.present? -%>
39
+ let(:valid_attributes) do
40
+ attributes_for(:<%=file_name%>)
41
+ .slice(*%i[<%= attribute_name %>])
42
+ .merge(
43
+ <% links.each do |relation| -%>
44
+ <%= relation.name %>_id: create(:<%= relation.name %>).id,
45
+ <% end -%>
46
+ )
47
+ end
48
+ <% else -%>
49
+ let(:valid_attributes) {attributes_for(:<%=file_name%>).slice *%i[<%= attribute_name %>]}
50
+ <% end -%>
51
+ <% else -%>
52
+ <% factory_bot = false -%>
53
+ let(:<%= file_name %>) {<%= class_name %>.create! valid_attributes}
54
+
55
+ let(:valid_attributes) do
56
+ skip("Add a hash of attributes valid for your model")
57
+ end
58
+ <% end -%>
59
+
60
+ let(:invalid_attributes) do
61
+ # {<%= attribute_name %>: ''}
62
+ skip("Add a hash of attributes invalid for your model")
63
+ end
64
+
65
+ # This should return the minimal set of values that should be in the headers
66
+ # in order to pass any filters (e.g. authentication) defined in
67
+ # <%= controller_class_name %>Controller, or in your router and rack
68
+ # middleware. Be sure to keep this updated too.
69
+ let(:valid_headers) do
70
+ {}
71
+ end
72
+
73
+ <% unless options[:singleton] -%>
74
+ describe "GET /index" do
75
+ subject(:get_index) do
76
+ get <%= index_helper %>_url, headers: valid_headers, as: :json
77
+ end
78
+
79
+ it "renders a successful response" do
80
+ <%= class_name %>.create! valid_attributes
81
+ get_index
82
+ expect(response).to be_successful
83
+ end
84
+ end
85
+ <% end -%>
86
+
87
+ describe "GET /show" do
88
+ subject(:get_show) do
89
+ get <%= file_name %>_url(id: <%= file_name %>.to_param),
90
+ headers: valid_headers, as: :json
91
+ end
92
+
93
+ it "renders a successful response" do
94
+ <% unless factory_bot -%>
95
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
96
+ <% end -%>
97
+ get_show
98
+ expect(response).to be_successful
99
+ end
100
+ end
101
+
102
+ describe "POST /create" do
103
+ subject(:post_create) do
104
+ post <%= index_helper %>_url, params: { <%= ns_file_name %>: attributes },
105
+ headers: valid_headers, as: :json
106
+ end
107
+
108
+ context "with valid parameters" do
109
+ let(:attributes) {valid_attributes}
110
+
111
+ it "creates a new <%= class_name %>" do
112
+ expect{post_create}.to change(<%= class_name %>, :count).by(1)
113
+ end
114
+
115
+ it "renders a JSON response with the new <%= singular_table_name %>" do
116
+ post_create
117
+ expect(response.content_type).to match(a_string_including("application/json"))
118
+ end
119
+
120
+ it "returns http_status :created" do
121
+ post_create
122
+ expect(response).to have_http_status(:created)
123
+ end
124
+ end
125
+
126
+ context "with invalid parameters" do
127
+ let(:attributes) {invalid_attributes}
128
+
129
+ it "does not create a new <%= class_name %>" do
130
+ expect {post_create}.not_to change(<%= class_name %>, :count)
131
+ end
132
+
133
+ it "returns http_status :unprocessable_entity" do
134
+ post_create
135
+ expect(response).to have_http_status :unprocessable_entity
136
+ end
137
+
138
+ it "renders a JSON response with errors for the new <%= singular_table_name %>" do
139
+ post_create
140
+ expect(response.content_type).to match(a_string_including("application/json"))
141
+ end
142
+ end
143
+ end
144
+
145
+ describe "PATCH /update" do
146
+ subject(:patch_update) do
147
+ patch <%= file_name %>_url(id: <%= file_name %>.to_param),
148
+ params: { <%= singular_table_name %>: attributes },
149
+ headers: valid_headers, as: :json
150
+ end
151
+
152
+ context "with valid parameters" do
153
+ let(:attributes) { {<%= attribute_name %>: 'New value'} }
154
+
155
+ it "updates the requested <%= ns_file_name %>" do
156
+ # expect_any_instance_of(<%= class_name %>)
157
+ # .to receive(:update).with(attributes.inject({}){|_, (k, v)| _[k] = v.to_s; _})
158
+ <% unless factory_bot -%>
159
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
160
+ <% end -%>
161
+ patch_update
162
+ <%= file_name %>.reload
163
+ # skip("Add assertions for updated state")
164
+ expect(<%= file_name %>.<%= attribute_name %>).to eq 'New value'
165
+ end
166
+
167
+ it "renders a JSON response with the <%= singular_table_name %>" do
168
+ <% unless factory_bot -%>
169
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
170
+ <% end -%>
171
+ patch_update
172
+ expect(response.content_type).to match(a_string_including("application/json"))
173
+ end
174
+
175
+ it "returns http_status :ok" do
176
+ patch_update
177
+ expect(response).to have_http_status(:ok)
178
+ end
179
+ end
180
+
181
+ context "with invalid parameters" do
182
+ let(:attributes) {invalid_attributes}
183
+
184
+ it "returns http_status :unprocessable_entity" do
185
+ <% unless factory_bot -%>
186
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
187
+ <% end -%>
188
+ patch_update
189
+ expect(response).to have_http_status :unprocessable_entity
190
+ end
191
+
192
+ it "renders a JSON response with errors for the <%= singular_table_name %>" do
193
+ <% unless factory_bot -%>
194
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
195
+ <% end -%>
196
+ patch_update
197
+ expect(response.content_type).to match(a_string_including("application/json"))
198
+ end
199
+ end
200
+ end
201
+
202
+ describe "DELETE /destroy" do
203
+ subject(:delete_destroy) {delete <%= file_name %>_url(id: <%= file_name %>.to_param)}
204
+
205
+ it "destroys the requested <%= ns_file_name %>" do
206
+ <% if factory_bot -%>
207
+ <%= file_name %>
208
+ <% else -%>
209
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
210
+ <% end -%>
211
+ expect {delete_destroy}.to change(<%= class_name %>, :count).by(-1)
212
+ end
213
+
214
+ it "returns http_status :no_content" do
215
+ delete_destroy
216
+ expect(response).to have_http_status(:no_content)
217
+ end
218
+ end
219
+ end
220
+ <% end -%>
@@ -14,6 +14,10 @@ require 'rails_helper'
14
14
 
15
15
  <% module_namespacing do -%>
16
16
  describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %> do
17
+ <% if mountable_engine? -%>
18
+ include Engine.routes.url_helpers
19
+ <% end -%>
20
+
17
21
  <% if method = Rails.application.config.generators.options[:rails][:cancan] -%>
18
22
  <% method = 'current_user' unless Symbol === method -%>
19
23
  before :each do
@@ -2,18 +2,18 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: rspec_rails_scaffold_templates 3.2.1 ruby lib
5
+ # stub: rspec_rails_scaffold_templates 3.3.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "rspec_rails_scaffold_templates".freeze
9
- s.version = "3.2.1"
9
+ s.version = "3.3.0".freeze
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
- s.authors = ["Dmitri Koulikoff".freeze]
14
- s.date = "2024-05-18"
13
+ s.authors = ["Dimitri Kulk".freeze]
14
+ s.date = "2025-03-15"
15
15
  s.description = "RSpec scaffold generator templates that use FactoryGirl and WiceGrid".freeze
16
- s.email = "dima@koulikoff.de".freeze
16
+ s.email = "dimitri@kulk.eu".freeze
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE.txt",
19
19
  "README.rdoc"
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
31
31
  "lib/rspec_rails_scaffold_templates/generators/scaffold_generator.rb",
32
32
  "lib/rspec_rails_scaffold_templates/generators/templates/rspec/integration/request_spec.rb",
33
33
  "lib/rspec_rails_scaffold_templates/generators/templates/rspec/scaffold/api_controller_spec.rb",
34
+ "lib/rspec_rails_scaffold_templates/generators/templates/rspec/scaffold/api_request_spec.rb",
34
35
  "lib/rspec_rails_scaffold_templates/generators/templates/rspec/scaffold/controller_spec.rb",
35
36
  "lib/rspec_rails_scaffold_templates/generators/templates/rspec/scaffold/edit_spec.rb",
36
37
  "lib/rspec_rails_scaffold_templates/generators/templates/rspec/scaffold/index_spec.rb",
@@ -43,25 +44,15 @@ Gem::Specification.new do |s|
43
44
  ]
44
45
  s.homepage = "http://github.com/dima4p/rspec_rails_scaffold_templates".freeze
45
46
  s.licenses = ["MIT".freeze]
46
- s.rubygems_version = "3.1.4".freeze
47
+ s.rubygems_version = "3.5.22".freeze
47
48
  s.summary = "RSpec scaffold generator templates that use FactoryGirl and WiceGrid".freeze
48
49
 
49
- if s.respond_to? :specification_version then
50
- s.specification_version = 4
51
- end
50
+ s.specification_version = 4
52
51
 
53
- if s.respond_to? :add_runtime_dependency then
54
- s.add_development_dependency(%q<rspec>.freeze, ["~> 3.1"])
55
- s.add_development_dependency(%q<rdoc>.freeze, ["~> 4.1"])
56
- s.add_development_dependency(%q<bundler>.freeze, ["~> 2.3.9"])
57
- s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.0"])
58
- s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.0"])
59
- else
60
- s.add_dependency(%q<rspec>.freeze, ["~> 3.1"])
61
- s.add_dependency(%q<rdoc>.freeze, ["~> 4.1"])
62
- s.add_dependency(%q<bundler>.freeze, ["~> 2.3.9"])
63
- s.add_dependency(%q<jeweler>.freeze, ["~> 2.0"])
64
- s.add_dependency(%q<simplecov>.freeze, ["~> 0.0"])
65
- end
52
+ s.add_development_dependency(%q<rspec>.freeze, ["~> 3.1".freeze])
53
+ s.add_development_dependency(%q<rdoc>.freeze, ["~> 6.1".freeze])
54
+ s.add_development_dependency(%q<bundler>.freeze, ["~> 2.3.9".freeze])
55
+ s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.0".freeze])
56
+ s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.0".freeze])
66
57
  end
67
58
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_rails_scaffold_templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
- - Dmitri Koulikoff
7
+ - Dimitri Kulk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-18 00:00:00.000000000 Z
11
+ date: 2025-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '4.1'
33
+ version: '6.1'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '4.1'
40
+ version: '6.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.0'
83
83
  description: RSpec scaffold generator templates that use FactoryGirl and WiceGrid
84
- email: dima@koulikoff.de
84
+ email: dimitri@kulk.eu
85
85
  executables: []
86
86
  extensions: []
87
87
  extra_rdoc_files:
@@ -100,6 +100,7 @@ files:
100
100
  - lib/rspec_rails_scaffold_templates/generators/scaffold_generator.rb
101
101
  - lib/rspec_rails_scaffold_templates/generators/templates/rspec/integration/request_spec.rb
102
102
  - lib/rspec_rails_scaffold_templates/generators/templates/rspec/scaffold/api_controller_spec.rb
103
+ - lib/rspec_rails_scaffold_templates/generators/templates/rspec/scaffold/api_request_spec.rb
103
104
  - lib/rspec_rails_scaffold_templates/generators/templates/rspec/scaffold/controller_spec.rb
104
105
  - lib/rspec_rails_scaffold_templates/generators/templates/rspec/scaffold/edit_spec.rb
105
106
  - lib/rspec_rails_scaffold_templates/generators/templates/rspec/scaffold/index_spec.rb
@@ -128,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
129
  - !ruby/object:Gem::Version
129
130
  version: '0'
130
131
  requirements: []
131
- rubygems_version: 3.1.4
132
+ rubygems_version: 3.5.22
132
133
  signing_key:
133
134
  specification_version: 4
134
135
  summary: RSpec scaffold generator templates that use FactoryGirl and WiceGrid