Why are my functional tests failing?

Posted by Mongus Pong on Stack Overflow See other posts from Stack Overflow or by Mongus Pong
Published on 2010-05-29T00:21:35Z Indexed on 2010/05/29 0:22 UTC
Read the original article Hit count: 619

Filed under:
|

I have generated some scaffolding for my rails app.

I am running the generated tests and they are failing.

for example

  test "should create area" do
    assert_difference('Area.count') do
      post :create, :area => { :name => 'area1' }
    end

    assert_redirected_to area_path(assigns(:area))
  end

This test is failing saying that :

1) Failure: test_should_create_area(AreasControllerTest) [/test/functional/areas_controller_test.rb:16]: "Area.count" didn't change by 1. <3> expected but was <2>.

There is only one field in the model : name. I am populating this so it cant be because I am failing to populate the only field.

I can run the site and create an area with the name 'area1'. So reality is succeeding, but the test is failing.

I cant ask why its failing, because Im sure theres not enough information here for anyone here to know why. Im just stuck at knowing what avenues to go down to work out why the test is failing. Even putting puts into the code dont print out... What steps can I take to track this down?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about unit-testing