Sha256: 4f262583b65227d8b0bd024029e34c38cc65abc46562329ec65a7cc04180bdc4
Contents?: true
Size: 1.94 KB
Versions: 4
Compression:
Stored size: 1.94 KB
Contents
require File.expand_path("test_helper", __dir__) class FloatTest < SearchCop::TestCase def test_anywhere product = 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 = 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 = 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 = 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 = 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 = 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 = 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 = create(:product, price: 10.5) assert_includes Product.search("price <= 10.5"), product refute_includes Product.search("price <= 10.4"), product end def test_negative product = create(:product, price: -10) assert_includes Product.search("price = -10"), product refute_includes Product.search("price = -11"), product end def test_incompatible_datatype assert_raises SearchCop::IncompatibleDatatype do Product.unsafe_search "price: Value" end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
search_cop-1.2.3 | test/float_test.rb |
search_cop-1.2.2 | test/float_test.rb |
search_cop-1.2.1 | test/float_test.rb |
search_cop-1.2.0 | test/float_test.rb |