Sha256: 8bb4312bcf80db9de6fe981e4562ddb30f0d66312d97fec9230f53e43a0a26a4

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

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

class FloatTest < AttrSearchable::TestCase
  def test_anywhere
    product = FactoryGirl.create(:product, :price => 10.5, :created_at => Time.now - 1.day)

    assert_includes Product.search("10.5"), product
    refute_includes Product.search("11.5"), product
  end

  def test_includes
    product = FactoryGirl.create(:product, :price => 10.5)

    assert_includes Product.search("price: 10.5"), product
    refute_includes Product.search("price: 11.5"), product
  end

  def test_equals
    product = FactoryGirl.create(:product, :price => 10.5)

    assert_includes Product.search("price = 10.5"), product
    refute_includes Product.search("price = 11.5"), product
  end

  def test_equals_not
    product = FactoryGirl.create(:product, :price => 10.5)

    assert_includes Product.search("price != 11.5"), product
    refute_includes Product.search("price != 10.5"), product
  end

  def test_greater
    product = FactoryGirl.create(:product, :price => 10.5)

    assert_includes Product.search("price > 10.4"), product
    refute_includes Product.search("price < 10.5"), product
  end

  def test_greater_equals
    product = FactoryGirl.create(:product, :price => 10.5)

    assert_includes Product.search("price >= 10.5"), product
    refute_includes Product.search("price >= 10.6"), product
  end

  def test_less
    product = FactoryGirl.create(:product, :price => 10.5)

    assert_includes Product.search("price < 10.6"), product
    refute_includes Product.search("price < 10.5"), product
  end

  def test_less_equals
    product = FactoryGirl.create(:product, :price => 10.5)

    assert_includes Product.search("price <= 10.5"), product
    refute_includes Product.search("price <= 10.4"), product
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
attr_searchable-0.0.1 test/float_test.rb