Preferred syntax:
expect(@object).to be_a Shirt
Older syntax:
@object.should be_an_instance_of Shirt
Please note that there is a very subtle difference between the two. If Shirt were to inherit from Garment, then both of these expectations will pass :
expect(@object).to be_a Shirt expect(@object).to be_a Garment
If you do this and @object is a Shirt, then the second wait will not be :
@object.should be_an_instance_of Shirt @object.should be_an_instance_of Garment
Dillon Benson Dec 20 '12 at 4:19 2012-12-20 04:19
source share