Sha256: 5fd7da356e9fc53d3eb995b7a1ad064cfcfaca02aeb0b039983c9682a85c8fa5

Contents?: true

Size: 917 Bytes

Versions: 4

Compression:

Stored size: 917 Bytes

Contents

require File.expand_path("test_helper", __dir__)

class AndTest < SearchCop::TestCase
  def test_and_string
    expected = create(:product, title: "expected title", description: "Description")
    rejected = create(:product, title: "Rejected title", description: "Description")

    results = Product.search("title: 'Expected title' description: Description")

    assert_includes results, expected
    refute_includes results, rejected

    assert_equal results, Product.search("title: 'Expected title' AND description: Description")
  end

  def test_and_hash
    expected = create(:product, title: "Expected title", description: "Description")
    rejected = create(:product, title: "Rejected title", description: "Description")

    results = Product.search(and: [{ title: "Expected title" }, { description: "Description" }])

    assert_includes results, expected
    refute_includes results, rejected
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
search_cop-1.2.3 test/and_test.rb
search_cop-1.2.2 test/and_test.rb
search_cop-1.2.1 test/and_test.rb
search_cop-1.2.0 test/and_test.rb