File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed
lib/generators/rspec/controller/templates
spec/generators/rspec/controller Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change 1
1
require 'rails_helper'
2
2
3
3
RSpec . describe "<%= class_name.pluralize %>" , <%= type_metatag ( :request ) %> do
4
- describe "GET /<%= name.underscore.pluralize %>" do
5
- it "works! (now write some real specs)" do
4
+ <% namespaced_path = regular_class_path.join('/') %>
5
+ <% for action in actions -%>
6
+ describe "GET /<%= action %>" do
7
+ it "returns http success" do
8
+ get "<%= "/#{ namespaced_path } " if namespaced_path != '' %>/<%= file_name %>/<%= action %>"
9
+ expect(response).to have_http_status(:success)
6
10
end
7
11
end
12
+
13
+ <% end -%>
8
14
end
Original file line number Diff line number Diff line change 26
26
end
27
27
it { is_expected . not_to exist }
28
28
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
29
53
end
30
54
31
55
describe 'view specs' do
You can’t perform that action at this time.
0 commit comments