diff --git a/spec/query_scopes_spec.rb b/spec/query_scopes_spec.rb index 097940d..9c77396 100644 --- a/spec/query_scopes_spec.rb +++ b/spec/query_scopes_spec.rb @@ -138,8 +138,8 @@ describe "#not_jsonb_contains" do it 'generates a negated query' do query = klass.not_jsonb_contains(str: 'foo') - - expect(query.to_sql).to match(/WHERE \(?NOT \(products.json_attributes @> \('{"str":"foo"}'\)::jsonb\)/) + # Rails 8 has double parens for some reason, previous does not + expect(query.to_sql).to match(/WHERE \(?NOT \(?\(products.json_attributes @> \('{"str":"foo"}'\)::jsonb\)\)?/) end end diff --git a/spec/type/polymorphic_type_spec.rb b/spec/type/polymorphic_type_spec.rb index e3cc68f..fade198 100644 --- a/spec/type/polymorphic_type_spec.rb +++ b/spec/type/polymorphic_type_spec.rb @@ -262,15 +262,18 @@ describe "not_jsonb_contains" do it "can create keypath query" do sql = klass.not_jsonb_contains("one_poly.bool" => true).to_sql - expect(sql).to match(/WHERE \(?NOT \(products.json_attributes @> \('{\"one_poly\":{\"bool\":true}}'\)/) + # Rails 8 has double parens for some reason, previous does not + expect(sql).to match(/WHERE \(?NOT \(?\(products.json_attributes @> \('{\"one_poly\":{\"bool\":true}}'\)\)?/) end it "can create keypath query with type" do sql = klass.not_jsonb_contains("one_poly" => {"bool" => true, "type" => "Model2"}).to_sql - expect(sql).to match(/WHERE \(?NOT \(products.json_attributes @> \('{\"one_poly\":{\"bool\":true,\"type\":\"Model2\"}}'\)/) + # Rails 8 has double parens for some reason, previous does not + expect(sql).to match(/WHERE \(?NOT \(?\(products.json_attributes @> \('{\"one_poly\":{\"bool\":true,\"type\":\"Model2\"}}'\)\)?/) end it "can create keypath query with model arg" do sql = klass.not_jsonb_contains("one_poly" => model2.new(bool: true)).to_sql - expect(sql).to match(/WHERE \(?NOT \(products.json_attributes @> \('{\"one_poly\":{\"bool\":true,\"type\":\"Model2\"}}'\)/) + # Rails 8 has double parens for some reason, previous does not + expect(sql).to match(/WHERE \(?NOT \(?\(products.json_attributes @> \('{\"one_poly\":{\"bool\":true,\"type\":\"Model2\"}}'\)\)?/) end end end