|
5 | 5 | RSpec.describe Rspec::Generators::ControllerGenerator, :type => :generator do
|
6 | 6 | setup_default_destination
|
7 | 7 |
|
8 |
| - describe 'request specs' do |
9 |
| - subject { file('spec/requests/posts_request_spec.rb') } |
10 |
| - |
| 8 | + describe 'controller specs' do |
| 9 | + subject { file('spec/controllers/posts_controller_spec.rb') } |
11 | 10 | describe 'generated by default' do
|
12 | 11 | before do
|
13 |
| - run_generator %w[posts] |
| 12 | + run_generator %w(posts) |
14 | 13 | end
|
15 | 14 |
|
16 | 15 | describe 'the spec' do
|
17 | 16 | it { is_expected.to exist }
|
18 | 17 | it { is_expected.to contain(/require 'rails_helper'/) }
|
19 |
| - it { is_expected.to contain(/^RSpec.describe "Posts", #{type_metatag(:request)}/) } |
| 18 | + it { is_expected.to contain(/^RSpec.describe PostsController, #{type_metatag(:controller)}/) } |
20 | 19 | end
|
21 | 20 | end
|
22 |
| - |
23 | 21 | describe 'skipped with a flag' do
|
24 | 22 | before do
|
25 |
| - run_generator %w[posts --no-request_specs] |
| 23 | + run_generator %w(posts --no-controller_specs) |
26 | 24 | end
|
27 | 25 | it { is_expected.not_to exist }
|
28 | 26 | end
|
29 |
| - |
30 |
| - |
31 |
| - describe 'with actions' do |
32 |
| - before do |
33 |
| - run_generator %w[posts index custom_action] |
34 |
| - end |
35 |
| - |
36 |
| - it { is_expected.to exist } |
37 |
| - it { is_expected.to contain('get "/posts/index"') } |
38 |
| - it { is_expected.to contain('get "/posts/custom_action"') } |
39 |
| - end |
40 |
| - |
41 |
| - describe 'with namespace and actions' do |
42 |
| - subject { file('spec/requests/admin/external/users_request_spec.rb') } |
43 |
| - |
44 |
| - before do |
45 |
| - run_generator %w[admin::external::users index custom_action] |
46 |
| - end |
47 |
| - |
48 |
| - it { is_expected.to exist } |
49 |
| - it { is_expected.to contain(/^RSpec.describe "Admin::External::Users", #{type_metatag(:request)}/) } |
50 |
| - it { is_expected.to contain('get "/admin/external/users/index"') } |
51 |
| - it { is_expected.to contain('get "/admin/external/users/custom_action"') } |
52 |
| - end |
53 | 27 | end
|
54 | 28 |
|
55 | 29 | describe 'view specs' do
|
|
153 | 127 | it { is_expected.not_to exist }
|
154 | 128 | end
|
155 | 129 | end
|
156 |
| - |
157 |
| - describe 'controller specs' do |
158 |
| - subject { file('spec/controllers/posts_controller_spec.rb') } |
159 |
| - |
160 |
| - describe 'are not generated' do |
161 |
| - it { is_expected.not_to exist } |
162 |
| - end |
163 |
| - |
164 |
| - describe 'with --controller-specs flag' do |
165 |
| - before do |
166 |
| - run_generator %w[posts --controller-specs] |
167 |
| - end |
168 |
| - |
169 |
| - describe 'the spec' do |
170 |
| - it { is_expected.to exist } |
171 |
| - it { is_expected.to contain(/require 'rails_helper'/) } |
172 |
| - it { is_expected.to contain(/^RSpec.describe PostsController, #{type_metatag(:controller)}/) } |
173 |
| - end |
174 |
| - end |
175 |
| - |
176 |
| - describe 'with --no-controller_specs flag' do |
177 |
| - before do |
178 |
| - run_generator %w[posts --no-controller-specs] |
179 |
| - end |
180 |
| - it { is_expected.not_to exist } |
181 |
| - end |
182 |
| - end |
183 | 130 | end
|
0 commit comments