diff --git a/lib/generators/rspec/scaffold/templates/index_spec.rb b/lib/generators/rspec/scaffold/templates/index_spec.rb index ed07d3fda..bf0381078 100644 --- a/lib/generators/rspec/scaffold/templates/index_spec.rb +++ b/lib/generators/rspec/scaffold/templates/index_spec.rb @@ -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 -%> diff --git a/spec/generators/rspec/scaffold/scaffold_generator_spec.rb b/spec/generators/rspec/scaffold/scaffold_generator_spec.rb index d07072a66..0d2d07d9b 100644 --- a/spec/generators/rspec/scaffold/scaffold_generator_spec.rb +++ b/spec/generators/rspec/scaffold/scaffold_generator_spec.rb @@ -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 diff --git a/spec/rspec/rails/matchers/action_cable/have_stream_spec.rb b/spec/rspec/rails/matchers/action_cable/have_stream_spec.rb index f257d2c9a..c592ea82e 100644 --- a/spec/rspec/rails/matchers/action_cable/have_stream_spec.rb +++ b/spec/rspec/rails/matchers/action_cable/have_stream_spec.rb @@ -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 @@ -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