나는 RSpec을 배우기 위해 노력 중입니다. 현재 built-in matchers을 공부하고 있습니다. RSpec kind? 잘못된 결과를 반환합니다
내가 relishapp site에expect(actual).to be_kind_of(expected)
에 조금 혼란 스러워요, 그것은 be_kind_of
의 행동이
obj.should be_kind_of (유형)로 말한다 : obj.kind_of 호출 (유형), 어떤 type이 obj의 클래스 계층에 있거나 모듈이고 obj의 클래스 계층에있는 클래스에 포함되어 있으면 true를 반환합니다.
APIdock 상태 this example : 나는 RSpec에 그것을 시험 때
module M; end
class A
include M
end
class B < A; end
class C < B; end
b.kind_of? A #=> true
b.kind_of? B #=> true
b.kind_of? C #=> false
b.kind_of? M #=> true
, 그것은 내가 할 때 false를 반환 : 예 말할 때
module M; end
class A
include M
end
class B < A; end
class C < B; end
describe "RSpec expectation" do
context "comparisons" do
let(:b) {B.new}
it "test types/classes/response" do
expect(b).to be kind_of?(A)
expect(b).to_not be_instance_of(A)
end
end
end
1) RSpec expectation comparisons test types/classes/response
Failure/Error: expect(b).to be kind_of?(A)
expected false
got #<B:70361555406320> => #<B:0x007ffca7081be0>
왜 내 RSpec에 false를 반환하지 그것은
true
을 반환해야합니까?