2012-03-13 3 views
2

안녕하세요, 내 응용 프로그램의 기능 부품을 테스트 할 때 기본적으로 테스트가 실행되지만 다음과 같은 오류가 발생하지만 참조하는 내용을 모르는 이러한 오류가 발생합니다.테스트 레일 기능을 할 때 오류가 발생했습니다

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 

을 필요로?

+0

후 당신의 관리자 또는 카트 컨트롤러 테스트를. – James

답변

-1

테스트 데이터베이스를 생성했는지 확인하십시오.

+0

무슨 뜻인지 모르겠다. –

+0

픽스쳐 yml을 설정했지만 테스트를 시도 할 때도 여전히 동일한 오류가 발생합니다. –

+0

이 답변은 잘못 쓰여 있습니다. "테스트 데이터베이스를 만들었습니까?"라는 뜻입니까? –

1

조명기를로드하는 데 문제가있는 것처럼 보입니다. setup 정의에서 carts 방법을 해결하는 방법을 알 수 없습니다.

test/fixtures/ 디렉토리에 설정 했습니까?

는 적절하게 설정하는 방법에 대한 정보에 대한 rails testing guide 참조,하지만 난 당신이 이런 걸 원하는 것 같은데요 :

test/fixtures/carts.yml :

one: 
    name: bork 
    foo_attribute: bar_value 
two: 
    name: other_cart 
    foo_attribute: blah_value 
+0

지금 내 비품을 살펴보고 그것에 대해 다시 알게 될 것입니다. –

관련 문제