Sha256: f7473fb2ebd67a3e23bfa485a76896d1f6f6254f4f07bf8ed3fc50dca4588efb

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

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

class BooleanTest < AttrSearchable::TestCase
  def test_mapping
    product = FactoryGirl.create(:product, :available => true)

    assert_includes Product.search("available: 1"), product
    assert_includes Product.search("available: true"), product
    assert_includes Product.search("available: yes"), product

    product = FactoryGirl.create(:product, :available => false)

    assert_includes Product.search("available: 0"), product
    assert_includes Product.search("available: false"), product
    assert_includes Product.search("available: no"), product
  end

  def test_anywhere
    product = FactoryGirl.create(:product, :available => true)

    assert_includes Product.search("true"), product
    refute_includes Product.search("false"), product
  end

  def test_includes
    product = FactoryGirl.create(:product, :available => true)

    assert_includes Product.search("available: true"), product
    refute_includes Product.search("available: false"), product
  end

  def test_equals
    product = FactoryGirl.create(:product, :available => true)

    assert_includes Product.search("available = true"), product
    refute_includes Product.search("available = false"), product
  end

  def test_equals_not
    product = FactoryGirl.create(:product, :available => false)

    assert_includes Product.search("available != true"), product
    refute_includes Product.search("available != false"), product
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
attr_searchable-0.0.1 test/boolean_test.rb