2013-10-20 94 views
0

我一直在分析代碼,但我找不到答案。失敗的rspec測試,但它應該通過

我得到運行的錯誤下一規格:

describe 'with valid information' do 
    before { 
    fill_in 'Name', with: 'Example User' 
    fill_in 'Email', with: '[email protected]' 
    fill_in 'Password', with: 'foobar' 
    fill_in 'Confirmation', with: 'foobar' 
    } 

    it 'should create a user' do 
    expect {click_button submit}.to change(User, :count).by(1) 
    end 

    describe "after saving the user" do 
    before {click_button submit} 
    let(:user) {User.find_by_email('[email protected]')} 

    it {should have_selector('title', text:user.name)} 
    it {should have_selector('div.alert.alert-success', text: "Welcome")} 
    end 

end 

誤差與零件,並檢查選擇div.alert.alert-成功「節省了用戶後」:

Failure/Error: it {should have_selector('div.alert.alert-success', text: "Welcome")} 
    expected css "div.alert.alert-success" with text "Welcome" to return something 

我users_controller發出閃光的散列與成功的關鍵:

flash[:succes] = "Welcome" 
redirect_to @user 

即使成功註冊後發送標籤div的帶class =頁面「警報警報不成功」:

<div class="alert alert-succes"> 
    Welcome 
</div> 

有沒有辦法知道什麼是渲染click_button測試提交所以我可以看到發生了什麼事?一些辦法看到生成的HTML從它導致控制檯

注意這是值得的說,如果我的測試改爲只應該have_selector(「div.alert」,文:「歡迎光臨」(沒有警報,成功類),它通過事先

回答

2

查找和替換「更迭」與「成功」

感謝。應該幫助

+0

哎呀我感到麻木:(。感謝的人! – JGutierrezC