Created
June 3, 2012 21:00
-
-
Save visibletrap/2865037 to your computer and use it in GitHub Desktop.
Minitest or SimpleDelagator problem?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby q.rb | |
1 true | |
2 false | |
3 true | |
4 false | |
5 A | |
Run options: --seed 65268 | |
# Running tests: | |
FF | |
Finished tests in 0.001205s, 1659.7510 tests/s, 1659.7510 assertions/s. | |
1) Failure: | |
test_0001_should_be_a_kind_of_a(X) [q.rb:21]: | |
Expected #<B:0x007fa9a9894ef0> to be a kind of A, not B. | |
2) Failure: | |
test_0002_should_be_an_instance_of_a(X) [q.rb:24]: | |
Expected #<B:0x007fa9a9894ef0> to be an instance of A, not B. | |
2 tests, 2 assertions, 2 failures, 0 errors, 0 skips |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'delegate' | |
class A < SimpleDelegator | |
def initialize(obj) | |
super(obj) | |
end | |
end | |
class B; end | |
x = A.new(B.new) | |
puts "1 #{x.kind_of?(A)}" | |
puts "2 #{x.kind_of?(B)}" | |
puts "3 #{x.instance_of?(A)}" | |
puts "4 #{x.instance_of?(B)}" | |
puts "5 #{x.class}" | |
require 'minitest/autorun' | |
require 'minitest/spec' | |
describe "X" do | |
it "should be a kind of A" do | |
x.must_be_kind_of(A) | |
end | |
it "should be an instance of A" do | |
x.must_be_instance_of(A) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment