test/duck_test.rb in must-0.2.6 vs test/duck_test.rb in must-0.2.7
- old
+ new
@@ -78,6 +78,20 @@
# failed
assert_equal false, 1.must.duck?("#bar") # instance object
assert_equal false, ClassFoo.must.duck?("#bar")
assert_equal false, ModuleFoo.must.duck?("#bar")
end
+
+ def test_duck_bang
+ assert_equal "1", 1.must.duck!("to_s")
+ end
+
+ def test_duck_bang_raises_if_not_defined
+ assert_raise(Must::Invalid) {
+ ClassFoo.must.duck!("foo")
+ }
+ end
+
+ def test_duck_bang_calls_block_if_not_defined
+ assert_equal 2, 1.must.duck!("to_xxx") { 2 }
+ end
end