diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b0473130..daeb88792 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,9 @@ jobs: RAILS_VERSION: 'main' # Rails 8.0 builds >= 3.2 + - ruby: 3.4.0-rc1 + env: + RAILS_VERSION: '~> 8.0.0' - ruby: 3.3 env: RAILS_VERSION: '~> 8.0.0' diff --git a/spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb b/spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb index 67d4a51c7..b6d4d913f 100644 --- a/spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb +++ b/spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb @@ -253,7 +253,7 @@ def broadcast(stream, msg) .from_channel(channel) .with(a_hash_including(a: :b)) .description - ).to eq("have broadcasted exactly 1 messages to my_stream with a hash including {:a => :b}") + ).to eq("have broadcasted exactly 1 messages to my_stream with a hash including #{{:a => :b}}") end end end diff --git a/spec/rspec/rails/matchers/be_a_new_spec.rb b/spec/rspec/rails/matchers/be_a_new_spec.rb index 76906a56f..e9b27f4f6 100644 --- a/spec/rspec/rails/matchers/be_a_new_spec.rb +++ b/spec/rspec/rails/matchers/be_a_new_spec.rb @@ -74,7 +74,13 @@ def new_record?; true; end expect { expect(record).to be_a_new(record.class).with( foo: a_string_matching("bar")) - }.to raise_error("attribute {\"foo\"=>(a string matching \"bar\")} was not set on #{record.inspect}") + }.to raise_error { |e| + if RUBY_VERSION >= '3.4' + "attribute {\"foo\" => (a string matching \"bar\")} was not set on #{record.inspect}" + else + "attribute {\"foo\"=>(a string matching \"bar\")} was not set on #{record.inspect}" + end + } end context "matcher is wrong type" do @@ -106,7 +112,13 @@ def new_record?; true; end foo: a_string_matching("foo"), bar: a_string_matching("barn") ) - }.to raise_error("attribute {\"bar\"=>(a string matching \"barn\")} was not set on #{record.inspect}") + }.to raise_error { |e| + if RUBY_VERSION >= '3.4' + "attribute {\"bar\" => (a string matching \"barn\")} was not set on #{record.inspect}" + else + "attribute {\"bar\"=>(a string matching \"barn\")} was not set on #{record.inspect}" + end + } end end end @@ -118,8 +130,13 @@ def new_record?; true; end expect(record).to be_a_new(record.class).with(zoo: 'zoo', car: 'car') }.to raise_error { |e| expect(e.message).to match(/attributes \{.*\} were not set on #{Regexp.escape record.inspect}/) - expect(e.message).to match(/"zoo"=>"zoo"/) - expect(e.message).to match(/"car"=>"car"/) + if RUBY_VERSION >= '3.4' + expect(e.message).to match(/"zoo" => "zoo"/) + expect(e.message).to match(/"car" => "car"/) + else + expect(e.message).to match(/"zoo"=>"zoo"/) + expect(e.message).to match(/"car"=>"car"/) + end } end end @@ -129,7 +146,7 @@ def new_record?; true; end expect { expect(record).to be_a_new(record.class).with(foo: 'bar') }.to raise_error( - %(attribute {"foo"=>"bar"} was not set on #{record.inspect}) + %(attribute #{{"foo"=>"bar"}} was not set on #{record.inspect}) ) end end @@ -166,8 +183,13 @@ def new_record?; false; end expect(record).to be_a_new(String).with(zoo: 'zoo', car: 'car') }.to raise_error { |e| expect(e.message).to match(/expected #{Regexp.escape record.inspect} to be a new String and attributes \{.*\} were not set on #{Regexp.escape record.inspect}/) - expect(e.message).to match(/"zoo"=>"zoo"/) - expect(e.message).to match(/"car"=>"car"/) + if RUBY_VERSION >= '3.4' + expect(e.message).to match(/"zoo" => "zoo"/) + expect(e.message).to match(/"car" => "car"/) + else + expect(e.message).to match(/"zoo"=>"zoo"/) + expect(e.message).to match(/"car"=>"car"/) + end } end end @@ -178,7 +200,7 @@ def new_record?; false; end expect(record).to be_a_new(String).with(foo: 'bar') }.to raise_error( "expected #{record.inspect} to be a new String and " + - %(attribute {"foo"=>"bar"} was not set on #{record.inspect}) + %(attribute #{{"foo"=>"bar"}} was not set on #{record.inspect}) ) end end diff --git a/spec/rspec/rails/matchers/be_routable_spec.rb b/spec/rspec/rails/matchers/be_routable_spec.rb index c3a6a1b15..362c39699 100644 --- a/spec/rspec/rails/matchers/be_routable_spec.rb +++ b/spec/rspec/rails/matchers/be_routable_spec.rb @@ -20,7 +20,7 @@ allow(routes).to receive(:recognize_path) { raise ActionController::RoutingError, 'ignore' } expect do expect({ get: "/a/path" }).to be_routable - end.to raise_error(/expected \{:get=>"\/a\/path"\} to be routable/) + end.to raise_error(/expected #{{:get=>"\/a\/path"}} to be routable/) end end @@ -37,7 +37,7 @@ allow(routes).to receive(:recognize_path) { { controller: "foo" } } expect do expect({ get: "/a/path" }).not_to be_routable - end.to raise_error(/expected \{:get=>"\/a\/path"\} not to be routable, but it routes to \{:controller=>"foo"\}/) + end.to raise_error(/expected #{{:get=>"\/a\/path"}} not to be routable, but it routes to #{{:controller=>"foo"}}/) end end end diff --git a/spec/rspec/rails/matchers/route_to_spec.rb b/spec/rspec/rails/matchers/route_to_spec.rb index ae49791f8..d432a9f64 100644 --- a/spec/rspec/rails/matchers/route_to_spec.rb +++ b/spec/rspec/rails/matchers/route_to_spec.rb @@ -9,7 +9,7 @@ def assert_recognizes(*) it "provides a description" do matcher = route_to("these" => "options") matcher.matches?(get: "path") - expect(matcher.description).to eq("route {:get=>\"path\"} to {\"these\"=>\"options\"}") + expect(matcher.description).to eq("route #{{:get=>"path"}} to #{{"these"=>"options"}}") end it "delegates to assert_recognizes" do @@ -109,7 +109,7 @@ def assert_recognizes(*) it "fails with custom message" do expect { expect({ get: "path" }).not_to route_to("these" => "options") - }.to raise_error(/expected \{:get=>"path"\} not to route to \{"these"=>"options"\}/) + }.to raise_error(/expected #{{:get=>"path"}} not to route to #{{"these"=>"options"}}/) end end