2016-04-25 86 views
0

我有一個功能測試,似乎沒有找到我期望的表的內容。我應該說我是新來的功能測試,所以這是肯定的,我做錯了。基本上我有一個組表,它需要組名和響應兩者都應顯示在表中,但在運行測試時不顯示。這是我的錯誤和代碼清晰。Rspec功能測試 - 驗證表中的內容

TEST

require "rails_helper" 

RSpec.feature "Edit 'Bounce Back' Message" do 
    scenario "Staff can change the response message" do 
    visit "/groups" 

    user = FactoryGirl.create(:user) 
    fill_in "Email", with: user.email 
    fill_in "Password", with: user.password 
    click_button "Sign in" 

    group = Group.create!(name: "Group A") 
    person = Person.create!(groups: [group], phone_number: "+161655555555") 

    expect(page).to have_content("You are now subscribed for updates") 
    expect(page).to have_content("Group A") 
    end 
end 

錯誤信息

This is the image

這裏是PAGE

This is the image

正如你可以看到它應該在顯示的響應和組名頁面但是它說它不顯示我期望的話?任何幫助將是偉大的!

VIEW

<div class="container text-center"> 
<div class="row"> 
<div class="text-center"> 
    <h3>Edit The "Bounce Back" Subscription Response</h3> 
<table class="table table-striped"> 
    <tbody> 
    <% @group.each do |group| %> 
     <tr> 
     <td class='edit_response'><%= group.name.capitalize %></td> 
     <td class='edit-response'><%= group.response %></td> 
     <td><%= link_to 'Edit', edit_group_path(group) %></td> 
     <tr> 
    <% end %> 
    </tbody> 
</table> 
</div> 
</div> 
</div> 

回答

1

既然你第一個也是唯一創造訂閱組之後,登錄用戶,除非你做一個刷新它不會在頁面上可見。也許嘗試在用戶登錄之前創建訂閱組?

scenario "Staff can change the response message" do 
    visit "/groups" 

    group = Group.create!(name: "Group A") 
    person = Person.create!(groups: [group], phone_number: "+161655555555") 

    user = FactoryGirl.create(:user) 
    fill_in "Email", with: user.email 
    fill_in "Password", with: user.password 
    click_button "Sign in" 

    expect(page).to have_content("You are now subscribed for updates") 
    expect(page).to have_content("Group A") 
end