Sha256: a9bd9bf4aee8b0a07b4567824628e99da4de993d0526e30b311fce90f5c6af74
Contents?: true
Size: 1.67 KB
Versions: 2
Compression:
Stored size: 1.67 KB
Contents
require 'test_helper' class EvalSupportTest < ActiveSupport::TestCase # Hash Tests def test_hash_string assert_equal "tag == 'todo'", conditions({:tag => 'todo'}) end def test_hash_number assert_equal "parent_id == 17", conditions({:parent_id => 17}) end def test_hash_true assert_equal "published == true", conditions({:published => true}) end def test_hash_false assert_equal "published == false", conditions({:published => false}) end def test_nil_value assert_equal "parent_id == nil", conditions({:parent_id => nil}) end def test_hash_multiple_conditions assert_include ["tag == 'todo'", "&&", "parent_id == 17"], conditions({:tag => 'todo', :parent_id => 17}) end # Array Tests def test_array_equal_string assert_equal "tag == 'todo'", conditions(["tag = ?", 'todo']) end def test_array_greater_number assert_equal "count >= 17", conditions(["count >= ?", 17]) end def test_array_multiple_conditions_with_and assert_include ["tag == 'todo'", "&&", "parent_id >= 17"], conditions(["tag = ? AND parent_id >= ?", 'todo', 17]) end def test_array_multiple_conditions_with_or assert_include ["tag == 'todo'", "||", "parent_id >= 17"], conditions(["tag = ? OR parent_id >= ?", 'todo', 17]) end # String Tests def test_string_multiple_conditions assert_include ["tag == 'todo'", "&&", "parent_id >= 17"], conditions("tag = 'todo' AND parent_id >= 17") end protected def conditions(cond) Positionable::EvalSupport.conditions_to_eval(cond) end def assert_include(arr, string) arr.each do |arr| assert_match arr, string end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
aguids-positionable-0.2.1 | test/rails_root/test/unit/eval_support_test.rb |
aguids-positionable-0.2.2 | test/rails_root/test/unit/eval_support_test.rb |