Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/generators/rspec/scaffold/templates/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@

it "renders a list of <%= ns_table_name %>" do
render
<% if Rails.version.to_f < 8.1 -%>
cell_selector = 'div>p'
<% else -%>
cell_selector = 'div>div>div'
<% end -%>
<% for attribute in output_attributes -%>
assert_select cell_selector, text: Regexp.new(<%= value_for(attribute) %>.to_s), count: 2
<% end -%>
Expand Down
9 changes: 8 additions & 1 deletion spec/generators/rspec/scaffold/scaffold_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,14 @@
.and(contain(/assign\(:posts, /))
.and(contain(/it "renders a list of (.*)"/))

expect(filename).to contain(/'div>p'/)
selector =
if Rails.version.to_f < 8.1
/'div>p'/
else
/'div>div>div'/
end

expect(filename).to contain(selector)
end
end

Expand Down
18 changes: 16 additions & 2 deletions spec/rspec/rails/matchers/action_cable/have_stream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,16 @@ def subscribed
it "fails with message" do
subscribe user: 42

broadcast_preamble =
if Rails.version.to_f < 8.1
"broadcast:StreamModel#"
else
"broadcast:"
end

expect {
expect(subscription).to have_stream_for(StreamModel.new(31_337))
}.to raise_error(/expected to have stream "broadcast:StreamModel#31337" started, but have \["broadcast:StreamModel#42"\]/)
}.to raise_error(/expected to have stream "#{broadcast_preamble}31337" started, but have \["#{broadcast_preamble}42"\]/)
end

context "with negated form" do
Expand All @@ -173,9 +180,16 @@ def subscribed
it "fails with message" do
subscribe user: 42

broadcast_id =
if Rails.version.to_f < 8.1
"broadcast:StreamModel#42"
else
"broadcast:42"
end

expect {
expect(subscription).not_to have_stream_for(StreamModel.new(42))
}.to raise_error(/expected not to have stream "broadcast:StreamModel#42" started, but have \["broadcast:StreamModel#42"\]/)
}.to raise_error(/expected not to have stream "#{broadcast_id}" started, but have \["#{broadcast_id}"\]/)
end
end
end
Expand Down