test/yargi/markable_test.rb in yargi-0.1.1 vs test/yargi/markable_test.rb in yargi-0.1.2
- old
+ new
@@ -14,10 +14,16 @@
assert_equal "world", @object.get_mark("hello")
@object.set_mark("hello", "world1")
assert_equal "world1", @object.get_mark("hello")
end
+ def test_has_mark
+ @object.set_mark("hello", "world")
+ assert @object.has_mark?("hello")
+ assert_equal false, @object.has_mark?("hello1")
+ end
+
def test_mark_set_and_get_though_hash_api
@object["hello"] = "world"
assert_equal "world", @object["hello"]
@object["hello"] = "world1"
assert_equal "world1", @object["hello"]
@@ -37,9 +43,33 @@
assert_nothing_raised do
@object.merge_marks "hello" => "marks"
end
assert_equal 1, @object[:merge_marks]
assert_equal "marks", @object["hello"]
+ end
+
+ def test_add_marks
+ @object.add_marks(:hello => 'world', :priority => 1.0)
+ assert_equal 'world', @object[:hello]
+ assert_equal 1.0, @object[:priority]
+ end
+
+ def test_add_marks_with_block
+ @object.add_marks do |v|
+ {:hello => 'world', :priority => 1.0, :debug => v.to_s}
+ end
+ assert_equal 'world', @object[:hello]
+ assert_equal 1.0, @object[:priority]
+ assert_not_nil @object[:debug]
+ end
+
+ def test_add_marks_with_both
+ @object.add_marks(:hello => 'world') do |v|
+ {:priority => 1.0, :debug => v.to_s}
+ end
+ assert_equal 'world', @object[:hello]
+ assert_equal 1.0, @object[:priority]
+ assert_not_nil @object[:debug]
end
def test_to_h
@object.set_mark(:me, "blambeau")
@object.add_marks(:hello => "world", :who => "yarvi", :nil => nil)