Skip to content

Commit 33f1292

Browse files
committed
Add namespaced request spec with --model-name.
- check if parameter name is not admin_post - check if test contains Post.create instead of Admin::Post.create related: #2534 (comment)
1 parent ed85fe1 commit 33f1292

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

spec/generators/rspec/scaffold/scaffold_generator_spec.rb

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,22 @@
101101

102102
describe 'namespaced request spec' do
103103
subject { file('spec/requests/admin/posts_spec.rb') }
104-
before { run_generator %w[admin/posts] }
105-
it { is_expected.to exist }
106-
it { is_expected.to contain(/^RSpec.describe "\/admin\/posts", #{type_metatag(:request)}/) }
107-
it { is_expected.to contain('admin_post_url(post)') }
108-
it { is_expected.to contain('Admin::Post.create') }
104+
105+
describe 'with no options' do
106+
before { run_generator %w[admin/posts] }
107+
it { is_expected.to exist }
108+
it { is_expected.to contain(/^RSpec.describe "\/admin\/posts", #{type_metatag(:request)}/) }
109+
it { is_expected.to contain('post admin_posts_url, params: { admin_post: valid_attributes }') }
110+
it { is_expected.to contain('admin_post_url(post)') }
111+
it { is_expected.to contain('Admin::Post.create') }
112+
end
113+
114+
describe 'with --model-name' do
115+
before { run_generator %w[admin/posts --model-name=post] }
116+
it { is_expected.to contain('post admin_posts_url, params: { post: valid_attributes }') }
117+
it { is_expected.not_to contain('params: { admin_post: valid_attributes }') }
118+
it { is_expected.to contain(' Post.create') }
119+
end
109120
end
110121

111122
describe 'namespaced controller spec' do

0 commit comments

Comments
 (0)