File tree Expand file tree Collapse file tree 3 files changed +25
-1
lines changed
lib/generators/rspec/scaffold/templates
spec/generators/rspec/scaffold Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 16
16
assert_select "form[action=?][method=?]", <%= ns_file_name %>_path(@<%= ns_file_name %>), "post" do
17
17
<% for attribute in output_attributes -%>
18
18
<%- name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name %>
19
+ <% if Rails.version.to_f >= 5.1 -%>
20
+ assert_select "<%= attribute.input_type -%>[name=?]", "<%= ns_file_name %>[<%= name %>]"
21
+ <% else -%>
19
22
assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= name %>[name=?]", "<%= ns_file_name %>[<%= name %>]"
23
+ <% end -%>
20
24
<% end -%>
21
25
end
22
26
end
Original file line number Diff line number Diff line change 15
15
assert_select "form[action=?][method=?]", <%= index_helper %>_path, "post" do
16
16
<% for attribute in output_attributes -%>
17
17
<%- name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name %>
18
+ <% if Rails.version.to_f >= 5.1 -%>
19
+ assert_select "<%= attribute.input_type -%>[name=?]", "<%= ns_file_name %>[<%= name %>]"
20
+ <% else -%>
18
21
assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= name %>[name=?]", "<%= ns_file_name %>[<%= name %>]"
22
+ <% end -%>
19
23
<% end -%>
20
24
end
21
25
end
Original file line number Diff line number Diff line change 111
111
it { is_expected . to contain ( 'assert_select "tr>td", :text => 3.5.to_s, :count => 2' ) }
112
112
end
113
113
114
- if Rails . version . to_f >= 4.0
114
+ case
115
+ when Rails . version . to_f >= 5.1
116
+ describe 'with reference attribute' do
117
+ before { run_generator %w( posts title:string author:references ) }
118
+ describe 'edit' do
119
+ subject { file ( "spec/views/posts/edit.html.erb_spec.rb" ) }
120
+ it { is_expected . to contain ( /assert_select "input\[ name=\? \] ", "post\[ author_id\] / ) }
121
+ it { is_expected . to contain ( /assert_select "input\[ name=\? \] ", "post\[ title\] / ) }
122
+ end
123
+
124
+ describe 'new' do
125
+ subject { file ( "spec/views/posts/new.html.erb_spec.rb" ) }
126
+ it { is_expected . to contain ( /assert_select "input\[ name=\? \] ", "post\[ author_id\] "/ ) }
127
+ it { is_expected . to contain ( /assert_select "input\[ name=\? \] ", "post\[ title\] / ) }
128
+ end
129
+ end
130
+ when Rails . version . to_f >= 4.0
115
131
describe 'with reference attribute' do
116
132
before { run_generator %w( posts title:string author:references ) }
117
133
describe 'edit' do
You can’t perform that action at this time.
0 commit comments