먼저 로그인이 올바르게 작동한다고 가정 해 보겠습니다. 사용자가 확실히 로그인했습니다. 나는 또한 게시물이 제대로 일어나고 있는지 확신한다. (메시지와 플러시를 점검하여 확실하다). 그리고 테스트가 설명 하듯이 증분의 실제 동작은 정상적으로 작동합니다. 테스트 만 실패합니다. 왜 관련 사양 작업을 고안하지 않습니까?
그러나 아래이 RSpec에있는
:it "should increase the strength ability by one point and also update the strength_points by one if strength is the trained ability" do
@user.str = 10
@user.str_points = 0
post :train_ability, :ability => 'str'
flash[:error].should be_nil
@user.str_points.should == 1
@user.str.should == 11
end
이 STR과 str_points shoulds 실패합니다. 사실 같은, (유증에 지정된대로) 내 매크로에 login_user 기능을 사용하고 있습니다 :
module ControllerMacros
def login_user
before(:each) do
@request.env["devise.mapping"] = :user
@user = Factory.create(:user)
sign_in @user
end
end
end
내가 @user 참으로 CURRENT_USER 것을 확신하지만 모든 속성의 변화가 실제로 발생하지 않는 것 같다 spec 내에서 @user (: user는 내가 만든 factory 임).
왜 작동하지 않습니까? :/
에 사양을 변경해보십시오! 고맙습니다, 지금 일했습니다! – Spyros