Use Shoulda's validate_uniqueness_of matcher correctly

Posted . Visible to the public. Deprecated.

Works without requiring an initial record in modern versions.

This raises "Could not find first Keyword":

describe Keyword do
  it { should validate_uniqueness_of(:text) }
end

Do this instead:

describe Keyword do

  it 'should have a unique #text' do
    Keyword.make
    should validate_uniqueness_of(:text)
  end

end

This is the intended behavior.

Henning Koch
Last edit
Keywords
rspec
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2010-09-08 14:44)