嗨,我测试我的应用程序的功能部分,基本上是测试运行,但我得到这些错误,我不知道它是指什么时,我得到以下错误。错误,当测试钢轨函数
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