Sha256: 5fde00482af088ace2916326350eca354c850eaf59e08d3c91df551c7d8d1c74

Contents?: true

Size: 952 Bytes

Versions: 10

Compression:

Stored size: 952 Bytes

Contents

require File.expand_path("../test_helper", __FILE__)

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

10 entries across 10 versions & 1 rubygems

Version Path
search_cop-1.0.9 test/and_test.rb
search_cop-1.0.8 test/and_test.rb
search_cop-1.0.7 test/and_test.rb
search_cop-1.0.6 test/and_test.rb
search_cop-1.0.5 test/and_test.rb
search_cop-1.0.4 test/and_test.rb
search_cop-1.0.3 test/and_test.rb
search_cop-1.0.2 test/and_test.rb
search_cop-1.0.1 test/and_test.rb
search_cop-1.0.0 test/and_test.rb