Topic: Unit test will not fail

Hi everyone,

I have a very simple table, 'area_links', which contains a foreign key, 'area_id' - integer - not null, and a 'url' - string - not null.

So, my unit test is as such:

def test_invalid
    area_link = AreaLink.new
    assert !area_link.valid?
    assert area_link.errors.invalid?(:area_id)
    assert area_link.errors.invalid?(:url)
  end

My console is returning:
  1) Failure:
test_invalid(AreaLinkTest) [test/unit/area_link_test.rb:13]:
<false> is not true.

Line #13 of my code is:
assert !area_link.valid?

What am I doing wrong? Help would be GREATLY appreciated.

Thanks,

Brandon Taylor
Sr. Developer

Dell

Re: Unit test will not fail

Have you added validation to your AreaLink model?

Railscasts - Free Ruby on Rails Screencasts

Re: Unit test will not fail

Haha...I'm a dork. No. Unfortunately. I forgot :-(

Thanks,

Brandon Taylor
Sr. Developer

Dell