Vita Rara: A Life Uncommon

Shoulda

Rspec & Shoulda: Specifying the Object Under Test


Categories: | |

Today we needed to test conditional validations on a model. We're using RSpec with the Shoulda macros to do this. Our model looks something like:

Shoulda: should_validate_uniqueness_of


Categories: | | |

When testing an ActiveRecord model that validates_uniqueness_of using Shoulda's should_validate_uniqueness_of macro it needs to be wrapped in a context where an instance of the model is created in the database. If there is no record in the database to validate against you'll get an error.

For more information see: Lighthouse Ticket.

Syndicate content