[rspec-users] Remarkable Rails validations not working

johnnybutler7 johnnybutler7 at gmail.com
Wed Jul 7 08:31:07 EDT 2010


Ive installed the remarkable_rails plugin(3.1.13) so i can use the
macros to test the model associations and validations.

For my model user i have:
 validates_presence_of   :title, :message => 'cannot be blank!'
 validates_length_of     :title, :within => 2..40, :too_short => 'is
too short!', :too_long => 'is too long!'

For my user_spec file i have:
describe "validations" do
  subject { Factory.build(:user) }

  it { should_validate_presence_of :title }
  it { should validate_length_of(:title, :within => 2..40) }


But when i run my specs i get errors:

'validations should require title to be set' FAILED
Expected User to require title to be set

'validations should ensure length of title is within 2..40 characters'
Expected User to be invalid when title length is less than 2

I cant understand why this isnt working? If i write regualr rspec code
it works, see below but i dont want to have to do this for every

  it "should be invalid without a title" do
     @user.title = nil
     @user.should_not be_valid
     @user.errors.on(:title).size.should == 2
     @user.errors.on(:title).should include("cannot be blank!")
     @user.errors.on(:title).should include("is too short!")

Has anyone got any ideas why the remarkable rails plugin is not
validating correctly?


More information about the rspec-users mailing list