I need a way to check if an object is an instance of another object using RSpec. For example:
describe "new shirt" do
it "should be an instance of a Shirt object"
# How can i check if it is an instance of a shirt object
end
end
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The preferred syntax is:
The older syntax is:
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:
If you do and @object is a Shirt, then the second expectation will fail: