How to fix Shoulda's âCan't find first xxxâ problem
In the following example, Shoulda's should_validate_uniqueness_of might throw an “Can't find first” error:
class PostTest < ActiveSupport::TestCase
should_validate_uniqueness_of :title
To fix it add a subject to the test:
class PostTest < ActiveSupport::TestCase
subject { Factory(:post) }
should_validate_uniqueness_of :title