Skip to content

Commit a589cb1

Browse files
committed
Added generators spec for rspec scaffold generator
1 parent 01488d8 commit a589cb1

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

spec/generators/rspec/scaffold/scaffold_generator_spec.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
it { is_expected.to contain('get post_url(post)') }
2121
it { is_expected.to contain('redirect_to(post_url(Post.last))') }
2222
it { is_expected.to contain(/"redirects to the \w+ list"/) }
23+
24+
if ::Rails::VERSION::STRING >= '7.0.0'
25+
it { is_expected.to contain(/renders a response with 422 status \(i.e. to display the 'new' template\)/) }
26+
it { is_expected.to contain(/renders a response with 422 status \(i.e. to display the 'edit' template\)/) }
27+
else
28+
it { is_expected.to contain(/renders a successful response \(i.e. to display the 'new' template\)/) }
29+
it { is_expected.to contain(/renders a successful response \(i.e. to display the 'edit' template\)/) }
30+
end
2331
end
2432

2533
describe 'with --no-request_specs' do
@@ -62,13 +70,21 @@
6270
it { is_expected.to contain(/^RSpec.describe PostsController, #{type_metatag(:controller)}/) }
6371
it { is_expected.to contain(/GET #new/) }
6472
it { is_expected.to contain(/"redirects to the created \w+"/) }
65-
it { is_expected.to contain(/display the 'new' template/) }
73+
if ::Rails::VERSION::STRING >= '7.0.0'
74+
it { is_expected.to contain(/renders a response with 422 status \(i.e. to display the 'new' template\)/) }
75+
else
76+
it { is_expected.to contain(/returns a success response \(i.e. to display the 'new' template\)/) }
77+
end
6678
it { is_expected.not_to contain(/"renders a JSON response with the new \w+"/) }
6779
it { is_expected.not_to contain(/"renders a JSON response with errors for the new \w+"/) }
6880

6981
it { is_expected.to contain(/GET #edit/) }
7082
it { is_expected.to contain(/"redirects to the \w+"/) }
71-
it { is_expected.to contain(/display the 'edit' template/) }
83+
if ::Rails::VERSION::STRING >= '7.0.0'
84+
it { is_expected.to contain(/renders a response with 422 status \(i.e. to display the 'edit' template\)/) }
85+
else
86+
it { is_expected.to contain(/returns a success response \(i.e. to display the 'edit' template\)/) }
87+
end
7288
it { is_expected.not_to contain(/"renders a JSON response with the \w+"/) }
7389
it { is_expected.not_to contain(/"renders a JSON response with errors for the \w+"/) }
7490

0 commit comments

Comments
 (0)