Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 84d504e

Browse files
committedAug 10, 2024
Move conditional cell_selector out of generated view spec
1 parent 9f4a5de commit 84d504e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 0 deletions
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)
Please sign in to comment.