2016-04-25 52 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