2012-09-02 8 views
5

मैं इस तरह किसी टिप्पणी का प्रतिसाद के लिए मेरी टिप्पणी को ध्यान में रखते एक कड़ी:त्रुटि

<%= link_to t('.reply', :default => t("helpers.links.reply")), new_story_comment_path(comment.story, parent_id: comment)%> 

परीक्षण में से कुछ हिस्सा इस तरह है:

it "replies to a comment" do 
    comment = FactoryGirl.create :comment, story_id: story.id, user_id: user.id 
    visit story_path story 
    save_and_open_page 
    click_link "reply" 
    current_path.should eq(new_story_comment_path story.id, parent_id: comment.id) 
    ... 
    end 

मैं इस त्रुटि मिलती है:

1) Comments replies to a comment 
    Failure/Error: current_path.should eq(new_story_comment_path story.id, parent_id: comment.id) 

     expected: "/stories/1/comments/new?parent_id=1" 
      got: "/stories/1/comments/new" 

     (compared using ==) 
    # ./spec/requests/comments_spec.rb:23:in `block (2 levels) in <top (required)>' 

मैं बचाने के साथ पेज की जाँच _and_open_page और लिंक सही है:

file:///stories/1/comments/new?parent_id=1 

मैं भी test.log फ़ाइल की जाँच की और मैं इस लाइन देख सकते हैं:

Started GET "/stories/1/comments/new?parent_id=1" for 127.0.0.1 at 2012-09-02 21:05:57 

मैं क्यों इस त्रुटि हर बार मिलता है, जबकि यह सही होना चाहिए?

उत्तर

6

current_path में केवल पथ शामिल है और इसमें यूआरएल पैरामीटर शामिल नहीं हैं। आपको संपूर्ण यूआरएल प्राप्त करने के लिए मौजूदा_यूआरएल का उपयोग करने की आवश्यकता होगी।

+0

धन्यवाद :) मुझे यूआरएल में सभी पथ बदलना पड़ा। – ArashM