spec/integration/associations_spec.rb in pg_search-0.7.4 vs spec/integration/associations_spec.rb in pg_search-0.7.5

- old
+ new

@@ -32,12 +32,12 @@ excluded = [ ModelWithoutAgainst.create!(:title => 'abcdef') ] results = ModelWithoutAgainst.with_another('abcdef') - results.map(&:title).should =~ included.map(&:title) - results.should_not include(excluded) + expect(results.map(&:title)).to match_array(included.map(&:title)) + expect(results).not_to include(excluded) end end context "through a belongs_to association" do with_model :AssociatedModel do @@ -68,12 +68,12 @@ ] excluded = ModelWithBelongsTo.create!(:title => 'mnopqr', :another_model => AssociatedModel.create!(:title => 'stuvwx')) results = ModelWithBelongsTo.with_associated('abcdef') - results.map(&:title).should =~ included.map(&:title) - results.should_not include(excluded) + expect(results.map(&:title)).to match_array(included.map(&:title)) + expect(results).not_to include(excluded) end end context "through a has_many association" do with_model :AssociatedModelWithHasMany do @@ -111,12 +111,12 @@ excluded = ModelWithHasMany.create!(:title => 'stuvwx', :other_models => [ AssociatedModelWithHasMany.create!(:title => 'abcdef') ]) results = ModelWithHasMany.with_associated('foo bar') - results.map(&:title).should =~ included.map(&:title) - results.should_not include(excluded) + expect(results.map(&:title)).to match_array(included.map(&:title)) + expect(results).not_to include(excluded) end it "uses an unscoped relation of the assocated model" do excluded = ModelWithHasMany.create!(:title => 'abcdef', :other_models => [ AssociatedModelWithHasMany.create!(:title => 'abcdef') @@ -127,12 +127,12 @@ AssociatedModelWithHasMany.create!(:title => 'bar') ]) ] results = ModelWithHasMany.limit(1).order("id ASC").with_associated('foo bar') - results.map(&:title).should =~ included.map(&:title) - results.should_not include(excluded) + expect(results.map(&:title)).to match_array(included.map(&:title)) + expect(results).not_to include(excluded) end end context "across multiple associations" do @@ -190,12 +190,12 @@ ]), ModelWithManyAssociations.create!(:title => 'qwerty', :model_of_second_type => unmatching_second) ] results = ModelWithManyAssociations.with_associated('foo bar') - results.map(&:title).should =~ included.map(&:title) - excluded.each { |object| results.should_not include(object) } + expect(results.map(&:title)).to match_array(included.map(&:title)) + excluded.each { |object| expect(results).not_to include(object) } end end context "on the same table" do with_model :DoublyAssociatedModel do @@ -245,12 +245,12 @@ DoublyAssociatedModel.create!(:title => "uiop") ]) ] results = ModelWithDoubleAssociation.with_associated('foo bar') - results.map(&:title).should =~ included.map(&:title) - excluded.each { |object| results.should_not include(object) } + expect(results.map(&:title)).to match_array(included.map(&:title)) + excluded.each { |object| expect(results).not_to include(object) } end end end context "against multiple attributes on one association" do @@ -298,13 +298,13 @@ ) ] results = ModelWithAssociation.with_associated('foo bar') - results.to_sql.scan("INNER JOIN").length.should == 1 - included.each { |object| results.should include(object) } - excluded.each { |object| results.should_not include(object) } + expect(results.to_sql.scan("INNER JOIN").length).to eq(1) + included.each { |object| expect(results).to include(object) } + excluded.each { |object| expect(results).not_to include(object) } end end context "against non-text columns" do @@ -337,12 +337,12 @@ excluded = [ Model.create!(:number => 123) ] results = Model.with_associated('123') - results.map(&:number).should =~ included.map(&:number) - results.should_not include(excluded) + expect(results.map(&:number)).to match_array(included.map(&:number)) + expect(results).not_to include(excluded) end end context "when including the associated model" do with_model :Parent do @@ -373,12 +373,12 @@ excluded = Parent.create!(:name => 'foo.bar') results = Parent.search_name('bar.foo').includes(:children) results.to_a - results.should include(included) - results.should_not include(excluded) + expect(results).to include(included) + expect(results).not_to include(excluded) end end end context "merging a pg_search_scope into another model's scope" do @@ -420,12 +420,12 @@ relation = AssociatedModel.search_content("foo") results = ModelWithAssociation.joins(:associated_models).merge(relation) - results.should include(*included) - results.should_not include(*excluded) + expect(results).to include(*included) + expect(results).not_to include(*excluded) end end context "chained onto a has_many association" do with_model :Company do @@ -461,12 +461,12 @@ Position.create!(:company_id => company.id, :title => "penn 1") ] results = company.positions.search('teller 1') - results.should include(*included) - results.should_not include(*excluded) + expect(results).to include(*included) + expect(results).not_to include(*excluded) end end context "chained onto a has_many association" do with_model :Company do @@ -503,10 +503,10 @@ Position.create!(company_id: company.id, title: "penn 1") ] results = company.positions.search('teller 1') - results.should include(*included) - results.should_not include(*excluded) + expect(results).to include(*included) + expect(results).not_to include(*excluded) end end end