basheps
basheps

Reputation: 10624

Changes to RSpec Error checking

I am trying to follow a tutorial on TDD with RSpec that contains the following line:

it 'must have a first_name' do
  p = Person.new
  p.should_not be_valid
  p.errors.on(:first_name).should_not be_nil
end

However I receive the following message in my test:

undefined method `on' for #ActiveModel::Errors:0x007fde0c3eceb0>

What is the correct way to write the code above.

Upvotes: 0

Views: 166

Answers (1)

Jim Mitchener
Jim Mitchener

Reputation: 9003

The correct function is errors_on. So that line should be

p.errors_on(:first_name).should_not be_nil

Upvotes: 2

Related Questions