Sha256: e99e4160ac99ac4f13199a85cc23252b1a182ffe8baa80ce4a78a2b147790ee0

Contents?: true

Size: 757 Bytes

Versions: 4

Compression:

Stored size: 757 Bytes

Contents

require File.expand_path("test_helper", __dir__)

class NotTest < SearchCop::TestCase
  def test_not_string
    expected = create(:product, title: "Expected title")
    rejected = create(:product, title: "Rejected title")

    results = Product.search("title: Title NOT title: Rejected")

    assert_includes results, expected
    refute_includes results, rejected

    assert_equal results, Product.search("title: Title -title: Rejected")
  end

  def test_not_hash
    expected = create(:product, title: "Expected title")
    rejected = create(:product, title: "Rejected title")

    results = Product.search(and: [{ title: "Title" }, { not: { title: "Rejected" } }])

    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/not_test.rb
search_cop-1.2.2 test/not_test.rb
search_cop-1.2.1 test/not_test.rb
search_cop-1.2.0 test/not_test.rb