嗨,我測試我的應用程序的功能部分,基本上是測試運行,但我得到這些錯誤,我不知道它是指什麼時,我得到以下錯誤。錯誤,當測試鋼軌函數
AdminControllerTest:
ERROR should get index (0.13s)
NoMethodError: undefined method `users' for #<AdminControllerTest:0x007fe9e0119000> /Users/@@@@@/Dropbox/blind/rack/ruby/1.9.1/gems/actionpack- 3.1.3/lib/action_dispatch/testing/assertions/routing.rb:175:in `method_missing'
CartsControllerTest:
ERROR should create cart (0.12s)
NoMethodError: undefined method `carts' for #<CartsControllerTest:0x007fe9de592b10>
/Users/@@@@@/Dropbox/blind/rack/ruby/1.9.1/gems/actionpack
3.1.3/lib/action_dispatch/testing/assertions/routing.rb:175:in `method_missing'
ERROR should destroy cart (0.17s)
NoMethodError: undefined method `carts' for #<CartsControllerTest:0x007fe9de3569a0>
/Users/@@@@@/Dropbox/blind/rack/ruby/1.9.1/gems/actionpack- 3.1.3/lib/action_dispatch/testing/assertions/routing.rb:175:in `method_missing'
ERROR should get edit (0.12s)
NoMethodError: undefined method `carts' for #<CartsControllerTest:0x007fe9e10c19d0>
/Users/@@@@@/Dropbox/blind/rack/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/testing/assertions/routing.rb:175:in `method_missing'
ERROR should get index (0.11s)
NoMethodError: undefined method `carts' for #<CartsControllerTest:0x007fe9e10604f0>
/Users/@@@@@/Dropbox/blind/rack/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/testing/assertions/routing.rb:175:in `method_missing'
ERROR should get new (0.11s)
NoMethodError: undefined method `carts' for #<CartsControllerTest:0x007fe9e1033fe0>
/Users/@@@@@/Dropbox/blind/rack/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/testing/assertions/routing.rb:175:in `method_missing'
ERROR should show cart (0.11s)
NoMethodError: undefined method `carts' for #<CartsControllerTest:0x007fe9e10109c8>
/Users/@@@@@/Dropbox/blind/rack/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/testing/assertions/routing.rb:175:in `method_missing'
ERROR should update cart (0.12s)
NoMethodError: undefined method `carts' for #<CartsControllerTest:0x007fe9de460558>
/Users/@@@@@/Dropbox/blind/rack/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/testing/assertions/routing.rb:175:in `method_missing'
車控制器測試 需要 'test_helper'
class CartsControllerTest < ActionController::TestCase
setup do
@cart = carts(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:carts)
end
test "should get new" do
get :new
assert_response :success
end
test "should create cart" do
assert_difference('Cart.count') do
post :create, cart: @cart.attributes
end
assert_redirected_to cart_path(assigns(:cart))
end
test "should show cart" do
get :show, id: @cart
assert_response :success
end
test "should get edit" do
get :edit, id: @cart
assert_response :success
end
什麼可能會造成這種情況發生?
發表您的管理員或推車控制器測試。 – James 2012-03-13 15:23:15