Skip to content

Commit 5036997

Browse files
mjankowskipirj
authored andcommitted
Move conditional cell_selector out of generated view spec
1 parent dc0abdb commit 5036997

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/generators/rspec/scaffold/templates/index_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
1919
it "renders a list of <%= ns_table_name %>" do
2020
render
21-
cell_selector = Rails::VERSION::STRING >= '7' ? 'div>p' : 'tr>td'
21+
cell_selector = <%= Rails::VERSION::STRING >= '7' ? "'div>p'" : "'tr>td'" %>
2222
<% for attribute in output_attributes -%>
2323
assert_select cell_selector, text: Regexp.new(<%= value_for(attribute) %>.to_s), count: 2
2424
<% end -%>

spec/generators/rspec/scaffold/scaffold_generator_spec.rb

+6
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@
268268
.and(contain(/^RSpec.describe "(.*)\/index", #{type_metatag(:view)}/))
269269
.and(contain(/assign\(:posts, /))
270270
.and(contain(/it "renders a list of (.*)"/))
271+
272+
if ::Rails::VERSION::STRING >= '7.0.0'
273+
expect(filename).to contain(/'div>p'/)
274+
else
275+
expect(filename).to contain(/'tr>td'/)
276+
end
271277
end
272278
end
273279

0 commit comments

Comments
 (0)