Sha256: 1fdf7564f7901ec0ce08c6a1549d6cff7c017643bd276c4221b34a710bf09e7b
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
require_relative '../../test_helper' DuckPuncher.punch! :Object class ObjectTest < MiniTest::Test def setup Object.const_set :User, Class.new @subject = Object.new @user = User.new end def teardown DuckPuncher::Ducks.list.delete_if { |duck| [:admin, :super_admin, :User].include?(duck.name) } Object.send :remove_const, :User end def test_clone! cloned = @subject.clone! assert_equal cloned.class, @subject.class refute_equal cloned, @subject end def test_punch_on_a_core_duck refute [].respond_to?(:m) assert [].respond_to?(:punch) assert [].punch.respond_to?(:m) end def test_punch_with_a_core_duck assert [].punch(:Array).respond_to?(:m) end def test_punch_on_a_custom_duck DuckPuncher.register :User, mod: 'CustomPunch2' assert @user.punch.respond_to?(:quack) end def test_punch_with_a_custom_duck refute @user.respond_to?(:quack) DuckPuncher.register :admin, mod: 'CustomPunch2' assert @user.punch(:admin).respond_to?(:quack) refute @user.respond_to?(:wobble) DuckPuncher.register :super_admin, mod: 'CustomPunch3' assert @user.punch(:super_admin).respond_to?(:wobble) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
duck_puncher-2.16.0 | test/lib/duck_puncher/object_test.rb |