pitosalas
pitosalas

Reputation: 10882

Why is Crystal .should be producing a spurious error

I am converting a Ruby program to Crystal as I learn it.

Here is an error message I am getting:

# Error
Failures:
  1) Test Rule class can return the name property
     Failure/Error: rule.name.should be "RpsIphone"

       Expected: "RpsIphone" (object_id: 4504126256)
            got: "RpsIphone" (object_id: 4524981536)

     # spec/rule_spec.cr:11

And here is the code that is causing it

# from spec
rule.name.should be "RpsIphone"

I also checked that the two strings when compared with .same? also say they are not the same. I've looked at those 9 characters over and over. What am I missing?

Upvotes: 1

Views: 60

Answers (1)

pitosalas
pitosalas

Reputation: 10882

  • Crystal's .should be tests for the objects being the same, identical, same object_id
  • Crystal's .should eq tests for the values being the same

Upvotes: 5

Related Questions