Skip to content

Commit 9781027

Browse files
committed
Fix generated specs for scaffold indexes
1 parent 8e0df8d commit 9781027

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
1919
it "renders a list of <%= ns_table_name %>" do
2020
render
21+
<% if Rails.version.to_f < 8.1 -%>
2122
cell_selector = 'div>p'
23+
<% else -%>
24+
cell_selector = 'div>div>div'
25+
<% end -%>
2226
<% for attribute in output_attributes -%>
2327
assert_select cell_selector, text: Regexp.new(<%= value_for(attribute) %>.to_s), count: 2
2428
<% end -%>

spec/generators/rspec/scaffold/scaffold_generator_spec.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,14 @@
264264
.and(contain(/assign\(:posts, /))
265265
.and(contain(/it "renders a list of (.*)"/))
266266

267-
expect(filename).to contain(/'div>p'/)
267+
selector =
268+
if Rails.version.to_f < 8.1
269+
/'div>p'/
270+
else
271+
/'div>div>div'/
272+
end
273+
274+
expect(filename).to contain(selector)
268275
end
269276
end
270277

0 commit comments

Comments
 (0)