2011-03-04 3 views
1

여기에 나는 this tutorial을 따르고 있으며 모든 것이 지금까지 잘 해결되었습니다.간단한 RSpec 테스트가 실패했습니다.

하지만 지금은 세션을 진행 한 것으로, 간단한 RSpec에 테스트가 실패 : 나는 RSpec을 실행하면

describe SessionsController do 

    #[...] 

    describe "GET 'new'" do 

    it "should have the right title" do 
     get :new 
     response.should have_selector("title", :content => "Sign in") 
    end 

    end 

    #[...] 

    describe "POST 'create'" do 

    #[...] 

    it "should have the right title" do 
     post :create, :session => @attr 
     response.should have_selector("title", :content => "Sign in") 
    end 

    #[...] 
    end 

end 

, 나는 항상 얻을 :

1) SessionsController GET 'new' should have the right title Failure/Error: response.should have_selector("title", :content => "Sign in
) expected following output to contain a Sign in tag: w3.org/TR/REC-html40/loose.dtd"> # ./spec/controllers/sessions_controller_spec.rb:14:in `block (3 levels) in '

내가 세션 액세스/새 페이지는 페이지는 다음과 같은 제목 태그 포함, 왜 테스트가 실패 할

<title>Ruby on Rails Tutorial Sample App | Sign in</title> 

모든 OTH 동안 비슷한 (= 제목 태그 테스트) 테스트가 잘 작동합니까?

class SessionsController < ApplicationController 
    def new 
    @title = 'Sign in' 
    end 

    def create 

    user = User.authenticate(params[:session][:email], params[:session][:password]) 

    if user.nil? 
     flash.now[:error] = "Invalid email/password combination." 
     @title = 'Sign in' 
     render 'new' 
    else 
     sign_in user 
     redirect_to user 
    end 
    end 


    def destroy 
     sign_out 
     redirect_to root_path  
    end 

end 

내가 잘못 여기서 뭐하는 거지 :

다음은 SessionController입니까? 당신의 도움이

답변

5

에 대한

들으 당신은 클래스의 상단에 render_views를 추가해야합니다. 그것 없이는 실제 html이 생성되지 않고 have_selector 테스트가 실패합니다.

+0

아, 멋지다. 트릭을 했어, thx – DeX3

관련 문제