|
6 | 6 | setup_default_destination
|
7 | 7 |
|
8 | 8 | describe 'request specs' do
|
9 |
| - subject { file('spec/requests/posts_spec.rb') } |
| 9 | + subject(:filename) { file('spec/requests/posts_spec.rb') } |
10 | 10 |
|
11 | 11 | describe 'generated by default' do
|
12 | 12 | before do
|
13 | 13 | run_generator %w[posts]
|
14 | 14 | end
|
15 | 15 |
|
16 |
| - describe 'the spec' do |
17 |
| - it { is_expected.to exist } |
18 |
| - it { is_expected.to contain(/require 'rails_helper'/) } |
19 |
| - it { is_expected.to contain(/^RSpec.describe "Posts", #{type_metatag(:request)}/) } |
20 |
| - it { is_expected.to contain('pending') } |
| 16 | + it 'includes the standard boilerplate' do |
| 17 | + expect(filename).to contain(/require 'rails_helper'/) |
| 18 | + .and(contain(/^RSpec.describe "Posts", #{type_metatag(:request)}/)) |
| 19 | + .and(contain('pending')) |
21 | 20 | end
|
22 | 21 | end
|
23 | 22 |
|
24 | 23 | describe 'skipped with a flag' do
|
25 | 24 | before do
|
26 | 25 | run_generator %w[posts --no-request_specs]
|
27 | 26 | end
|
28 |
| - it { is_expected.not_to exist } |
| 27 | + |
| 28 | + it 'skips the file' do |
| 29 | + expect(File.exist?(filename)).to be false |
| 30 | + end |
29 | 31 | end
|
30 | 32 |
|
31 | 33 | describe 'with actions' do
|
32 | 34 | before do
|
33 | 35 | run_generator %w[posts index custom_action]
|
34 | 36 | end
|
35 | 37 |
|
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"') } |
| 38 | + it 'includes the standard boilerplate' do |
| 39 | + expect(filename).to contain('get "/posts/index"') |
| 40 | + .and(contain('get "/posts/custom_action"')) |
| 41 | + end |
39 | 42 | end
|
40 | 43 |
|
41 | 44 | describe 'with namespace and actions' do
|
42 |
| - subject { file('spec/requests/admin/external/users_spec.rb') } |
| 45 | + subject(:filename) { file('spec/requests/admin/external/users_spec.rb') } |
43 | 46 |
|
44 | 47 | before do
|
45 | 48 | run_generator %w[admin::external::users index custom_action]
|
46 | 49 | end
|
47 | 50 |
|
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"') } |
| 51 | + it 'includes the standard boilerplate' do |
| 52 | + expect(filename).to contain(/^RSpec.describe "Admin::External::Users", #{type_metatag(:request)}/) |
| 53 | + .and(contain('get "/admin/external/users/index"')) |
| 54 | + .and(contain('get "/admin/external/users/custom_action"')) |
| 55 | + end |
52 | 56 | end
|
53 | 57 | end
|
54 | 58 |
|
|
58 | 62 | before do
|
59 | 63 | run_generator %w[posts index show --no-view-specs]
|
60 | 64 | end
|
| 65 | + |
61 | 66 | describe 'index.html.erb' do
|
62 |
| - subject { file('spec/views/posts/index.html.erb_spec.rb') } |
63 |
| - it { is_expected.not_to exist } |
| 67 | + subject(:filename) { file('spec/views/posts/index.html.erb_spec.rb') } |
| 68 | + |
| 69 | + it 'skips the file' do |
| 70 | + expect(File.exist?(filename)).to be false |
| 71 | + end |
64 | 72 | end
|
65 | 73 | end
|
| 74 | + |
66 | 75 | describe 'with no actions' do
|
67 | 76 | before do
|
68 | 77 | run_generator %w[posts]
|
69 | 78 | end
|
| 79 | + |
70 | 80 | describe 'index.html.erb' do
|
71 |
| - subject { file('spec/views/posts/index.html.erb_spec.rb') } |
72 |
| - it { is_expected.not_to exist } |
| 81 | + subject(:filename) { file('spec/views/posts/index.html.erb_spec.rb') } |
| 82 | + |
| 83 | + it 'skips the file' do |
| 84 | + expect(File.exist?(filename)).to be false |
| 85 | + end |
73 | 86 | end
|
74 | 87 | end
|
75 | 88 |
|
|
79 | 92 | end
|
80 | 93 |
|
81 | 94 | describe 'index.html.erb' do
|
82 |
| - subject { file('spec/views/posts/index.html._spec.rb') } |
83 |
| - it { is_expected.not_to exist } |
| 95 | + subject(:filename) { file('spec/views/posts/index.html._spec.rb') } |
| 96 | + |
| 97 | + it 'skips the file' do |
| 98 | + expect(File.exist?(filename)).to be false |
| 99 | + end |
84 | 100 | end
|
85 | 101 | end
|
86 | 102 | end
|
|
90 | 106 | before do
|
91 | 107 | run_generator %w[posts index show]
|
92 | 108 | end
|
| 109 | + |
93 | 110 | describe 'index.html.erb' do
|
94 |
| - subject { file('spec/views/posts/index.html.erb_spec.rb') } |
95 |
| - it { is_expected.to exist } |
96 |
| - it { is_expected.to contain(/require 'rails_helper'/) } |
97 |
| - it { is_expected.to contain(/^RSpec.describe "posts\/index.html.erb", #{type_metatag(:view)}/) } |
| 111 | + subject(:filename) { file('spec/views/posts/index.html.erb_spec.rb') } |
| 112 | + |
| 113 | + it 'includes the standard boilerplate' do |
| 114 | + expect(filename).to contain(/require 'rails_helper'/) |
| 115 | + .and(contain(/^RSpec.describe "posts\/index.html.erb", #{type_metatag(:view)}/)) |
| 116 | + end |
98 | 117 | end
|
| 118 | + |
99 | 119 | describe 'show.html.erb' do
|
100 |
| - subject { file('spec/views/posts/show.html.erb_spec.rb') } |
101 |
| - it { is_expected.to exist } |
102 |
| - it { is_expected.to contain(/require 'rails_helper'/) } |
103 |
| - it { is_expected.to contain(/^RSpec.describe "posts\/show.html.erb", #{type_metatag(:view)}/) } |
| 120 | + subject(:filename) { file('spec/views/posts/show.html.erb_spec.rb') } |
| 121 | + |
| 122 | + it 'includes the standard boilerplate' do |
| 123 | + expect(filename).to contain(/require 'rails_helper'/) |
| 124 | + .and(contain(/^RSpec.describe "posts\/show.html.erb", #{type_metatag(:view)}/)) |
| 125 | + end |
104 | 126 | end
|
105 | 127 | end
|
| 128 | + |
106 | 129 | describe 'with haml' do
|
107 | 130 | before do
|
108 | 131 | run_generator %w[posts index --template_engine haml]
|
109 | 132 | end
|
| 133 | + |
110 | 134 | describe 'index.html.haml' do
|
111 |
| - subject { file('spec/views/posts/index.html.haml_spec.rb') } |
112 |
| - it { is_expected.to exist } |
113 |
| - it { is_expected.to contain(/require 'rails_helper'/) } |
114 |
| - it { is_expected.to contain(/^RSpec.describe "posts\/index.html.haml", #{type_metatag(:view)}/) } |
| 135 | + subject(:filename) { file('spec/views/posts/index.html.haml_spec.rb') } |
| 136 | + |
| 137 | + it 'includes the standard boilerplate' do |
| 138 | + expect(filename).to contain(/require 'rails_helper'/) |
| 139 | + .and(contain(/^RSpec.describe "posts\/index.html.haml", #{type_metatag(:view)}/)) |
| 140 | + end |
115 | 141 | end
|
116 | 142 | end
|
117 | 143 | end
|
118 | 144 |
|
119 | 145 | describe 'are removed' do
|
120 |
| - subject { run_generator %w[posts], behavior: :revoke } |
121 |
| - it { is_expected.to match('remove spec/views/posts') } |
| 146 | + subject(:output) { run_generator %w[posts], behavior: :revoke } |
| 147 | + |
| 148 | + it 'will remove the file' do |
| 149 | + expect(output).to match('remove spec/views/posts') |
| 150 | + end |
122 | 151 | end
|
123 | 152 | end
|
124 | 153 |
|
125 | 154 | describe 'routing spec' do
|
126 |
| - subject { file('spec/routing/posts_routing_spec.rb') } |
| 155 | + subject(:filename) { file('spec/routing/posts_routing_spec.rb') } |
127 | 156 |
|
128 | 157 | describe 'with no flag' do
|
129 | 158 | before do
|
130 | 159 | run_generator %w[posts seek and destroy]
|
131 | 160 | end
|
132 |
| - it { is_expected.not_to exist } |
| 161 | + |
| 162 | + it 'skips the file' do |
| 163 | + expect(File.exist?(filename)).to be false |
| 164 | + end |
133 | 165 | end
|
134 | 166 |
|
135 | 167 | describe 'with --routing-specs flag' do
|
136 | 168 | describe 'without action parameter' do
|
137 | 169 | before do
|
138 | 170 | run_generator %w[posts --routing-specs]
|
139 | 171 | end
|
140 |
| - it { is_expected.not_to exist } |
| 172 | + |
| 173 | + it 'skips the file' do |
| 174 | + expect(File.exist?(filename)).to be false |
| 175 | + end |
141 | 176 | end
|
142 | 177 |
|
143 | 178 | describe 'with action parameter' do
|
144 | 179 | before { run_generator %w[posts seek --routing-specs] }
|
145 | 180 |
|
146 |
| - it { is_expected.to contain(/require 'rails_helper'/) } |
147 |
| - it { is_expected.to contain(/^RSpec.describe 'PostsController', #{type_metatag(:routing)}/) } |
148 |
| - it { is_expected.to contain(/describe 'routing'/) } |
149 |
| - it { is_expected.to contain(/it 'routes to #seek'/) } |
150 |
| - it { is_expected.to contain(/expect\(get: "\/posts\/seek"\).to route_to\("posts#seek"\)/) } |
| 181 | + it 'includes the standard boilerplate' do |
| 182 | + expect(filename).to contain(/require 'rails_helper'/) |
| 183 | + .and(contain(/^RSpec.describe 'PostsController', #{type_metatag(:routing)}/)) |
| 184 | + .and(contain(/describe 'routing'/)) |
| 185 | + .and(contain(/it 'routes to #seek'/)) |
| 186 | + .and(contain(/expect\(get: "\/posts\/seek"\).to route_to\("posts#seek"\)/)) |
| 187 | + end |
151 | 188 | end
|
152 | 189 | end
|
153 | 190 |
|
154 | 191 | describe 'with --no-routing-specs flag' do
|
155 | 192 | before do
|
156 | 193 | run_generator %w[posts seek and destroy --no-routing_specs]
|
157 | 194 | end
|
158 |
| - it { is_expected.not_to exist } |
| 195 | + |
| 196 | + it 'skips the file' do |
| 197 | + expect(File.exist?(filename)).to be false |
| 198 | + end |
159 | 199 | end
|
160 | 200 | end
|
161 | 201 |
|
162 | 202 | describe 'controller specs' do
|
163 |
| - subject { file('spec/controllers/posts_controller_spec.rb') } |
| 203 | + subject(:filename) { file('spec/controllers/posts_controller_spec.rb') } |
164 | 204 |
|
165 |
| - describe 'are not generated' do |
166 |
| - it { is_expected.not_to exist } |
| 205 | + it 'are not generated' do |
| 206 | + expect(File.exist?(filename)).to be false |
167 | 207 | end
|
168 | 208 |
|
169 | 209 | describe 'with --controller-specs flag' do
|
|
172 | 212 | end
|
173 | 213 |
|
174 | 214 | describe 'the spec' do
|
175 |
| - it { is_expected.to exist } |
176 |
| - it { is_expected.to contain(/require 'rails_helper'/) } |
177 |
| - it { is_expected.to contain(/^RSpec.describe PostsController, #{type_metatag(:controller)}/) } |
| 215 | + it 'includes the standard boilerplate' do |
| 216 | + expect(filename).to contain(/require 'rails_helper'/) |
| 217 | + .and(contain(/^RSpec.describe PostsController, #{type_metatag(:controller)}/)) |
| 218 | + end |
178 | 219 | end
|
179 | 220 | end
|
180 | 221 |
|
181 | 222 | describe 'with --no-controller_specs flag' do
|
182 | 223 | before do
|
183 | 224 | run_generator %w[posts --no-controller-specs]
|
184 | 225 | end
|
185 |
| - it { is_expected.not_to exist } |
| 226 | + |
| 227 | + it 'are skipped' do |
| 228 | + expect(File.exist?(filename)).to be false |
| 229 | + end |
186 | 230 | end
|
187 | 231 | end
|
188 | 232 | end
|
0 commit comments