简体   繁体   中英

Why are my functional tests failing?

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?

根据上面的请求,并且匹配您在挖掘日志时发现的预期,您将拥有在测试中无法满足的授权。

@request and @response are also useful objects to look at (ie puts @response inside your test). I don't know what authentication you are using, but check RAILS_ROOT/lib for authenticated_test_helper , or the /lib , or /test of your authentication gem. You'll find methods for performing a login.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM