2014-09-07 4 views
0

Capybara는 내 웹 페이지에서 버튼을 보지 못합니다. 여기 내 테스트 코드Ruby on Rails 4 Rspec, Capybara는 버튼을 보지 못합니다.

before(:each) do 
    @inspiring = PostMotivation.create(:title => "This is title",:body => "body main content",:short => "short content of this post",:date => "20.06.2014") 
    end 

    it "should redirect when you want to add new comment" do 
    visit "/inspiring" 
    click_button("add_comment") 
    end 

을 그리고 여기 내보기 볼 수 있습니다

<%= button_to new_main_dupa_path(0,0,@post_to_render3.id), class: "button",id: "add_comment" do %> 
     Add new comment! 
<% end %> 

오류는 다음과 같습니다

2) Testing inspiring subpage with integration tests should redirect when you want to add new comment 
    Failure/Error: click_button("add_comment") 
    Capybara::ElementNotFound: 
     Unable to find button "add_comment" 
    # ./spec/features/inspiring.rb:39:in `block (2 levels) in <top (required)>' 

어떻게 카피 바라가이 버튼을 볼 수 있도록를? 방금 ​​전에이 문제에 대한 해결책을 찾을 수 없었습니다.

답변

0

문제가 풀 렸습니다. 물론 실수가 있었고, "/ inspiring"방문을 통해 잊어 버렸습니다. 게시물 목록을 방문하고, 특정 의견을 추가하여 의견을 추가 할 수 있습니다. 그래서 지나가는 코드는 이렇게 보일 것입니다.

it "should redirect when you want to add new comment" do 
    visit "/inspiring" 
    click_link("inspiring_#{@inspiring.id}") 
    click_button("add_comment") 
    end