Rspec, shoulda, validate_uniqueness_of с областью и неправильным сообщением об ошибке

У меня есть следующий тест Rspec:

describe Productlimit do

  before(:each) do 
    @productlimit = Factory.create(:productlimit, :user => Factory.create(:user))
  end

  subject { @productlimit }

  ...

  it { should validate_uniqueness_of(:price_cents).scoped_to(:direction_down, :currency, :market_id, :user_id) }
  ...
end

Но я получаю следующую сбивающую с толку ошибку:

1) Productlimit 
     Failure/Error: it { should validate_uniqueness_of(:price_cents).scoped_to(:direction_down, :currency, :market_id, :user_id) }
       Expected errors to include "has already been taken" when price_cents is set to 9530, got errors: ["direction_down has already been taken (false)"]

Вы можете мне помочь? Я не понимаю, почему это не работает, потому что сообщение об ошибке кажется правильным?

РЕДАКТИРОВАТЬ:

Это происходит и в других ситуациях:

# product_spec.rb
...
it { should validate_numericality_of(:price).with_message("price_cents must be greater than 0 (0)") }  

# rake spec:models
Failure/Error: it { should validate_numericality_of(:price).with_message("price_cents must be greater than 0 (0)") }
   Expected errors to include "price_cents must be greater than 0 (0)" when price is set to "abcd", got errors: ["price_cents must be greater than 0 (0)"]
15
задан lucapette 23 November 2011 в 11:20
поделиться