Search code examples
ruby-on-railsrspecrspec-rails

How to write should_not be_valid with expect syntax


I am doing some tests while following codeschool course on rspec and I don't know how to write model validation for presence with expect syntax. If I write:

expect(user).should_not be_valid 

rspec is telling me to use expect instead of should_not. But I can not find how to write the right expression to check validation.


Solution

  • The expect syntax should be

    expect(user).not_to be_valid