File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed
lib/generators/rspec/scaffold/templates
spec/generators/rspec/scaffold Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change 53
53
end
54
54
55
55
it "redirects to the created <%= ns_file_name %>" do
56
- expect {
57
- post <%= "#{ index_helper } _path" %>, params: { <%= ns_file_name %>: valid_attributes }
58
- }.to redirect_to("<%= ns_table_name %>/#{ <%= class_name %>.last}")
56
+ post <%= "#{ index_helper } _path" %>, params: { <%= ns_file_name %>: valid_attributes }
57
+ expect(response).to redirect_to(<%= singular_table_name %>_url(<%= class_name %>.last))
59
58
end
60
59
end
61
60
62
61
context "with invalid parameters" do
63
62
it "does not create a new <%= class_name %>" do
64
63
expect {
65
64
post <%= "#{ index_helper } _path" %>, params: { <%= ns_file_name %>: invalid_attributes }
66
- } .not_to change(<%= class_name %>, :count).by(1 )
65
+ }.to change(<%= class_name %>, :count).by(0 )
67
66
end
68
67
69
68
it "renders a successful response (i.e. to display the 'new' template)" do
Original file line number Diff line number Diff line change 15
15
it { is_expected . to contain ( /^RSpec.describe PostsController, #{ type_metatag ( :request ) } / ) }
16
16
it { is_expected . to contain ( 'GET /new' ) }
17
17
it { is_expected . to contain ( /"redirects to the created post"/ ) }
18
- it { is_expected . to contain ( 'posts/#{ Post.last} ' ) }
18
+ it { is_expected . to contain ( 'post_url( Post.last) ' ) }
19
19
it { is_expected . to contain ( /"redirects to the \w + list"/ ) }
20
20
end
21
21
76
76
before { run_generator %w[ admin/posts --request_specs ] }
77
77
it { is_expected . to exist }
78
78
it { is_expected . to contain ( /^RSpec.describe Admin::PostsController, #{ type_metatag ( :request ) } / ) }
79
- it { is_expected . to contain ( 'admin/posts/#{ Admin::Post.last} ' ) }
79
+ it { is_expected . to contain ( 'admin_post_url( Admin::Post.last) ' ) }
80
80
end
81
81
82
82
describe 'namespaced controller spec' do
You can’t perform that action at this time.
0 commit comments