2009-11-23 1 views
0

내 팀의 다른 사람들이 추천 한대로 jQuery 툴팁 플러그인을 사용하여 페이지에 예쁜 툴팁을 추가하라는 요청에 대한 작업. 예쁜 툴팁이 잘 작동하지만, 기존의 스펙이 지금 실패 아래 예 : completness를 들어레일스에서 ​​뷰에 자바 스크립트를 추가 한 후 hml 태그를 제거하기위한 스펙을 수정하는 방법은 무엇입니까?

describe 'with a discussion post containing html' do 

    before(:each) do 
    @post.update_attributes(:body => "some <strong>bold and <i>italic</i></strong> text") 
    assigns[:posts] = @discussion.posts.paginate(:page => 1) 
    render 
    end 

    it 'should strip the html tags from the post body' do 
    response.should say('some bold and italic text') 
    end  
end 

, 여기에 내가 토론에 추가 한 자바 스크립트 보여 페이지와 결과 RSpec에 있습니다.

<script type="text/javascript" charset="utf-8"> 
    $(function(){ 
    $('#useful_item_submit').tooltip(); 
    }); 
</script> 

<div id="useful_item_form" > 
    <% form_for [flaggable, flaggable.useful_items.new] do |f| -%> 
    <div> 
     <%= f.submit "I find this useful", :title => 'Click to let others know you found this useful' %> 
    </div> 
    <% end -%> 
</div> 

나는 여분의 자바 스크립트를 무시하도록 테스트를 변경해야 또는 I는 show.html.erb 파일에 자바 스크립트를하지 말았어야? 사양 ============에서

출력

'discussions/show.html.erb with a discussion post containing html should strip the html tags from the post body' FAILED 
<"some bold and italic text"> expected but was 
<"some bold and italic text\n\t\t\n $(function(){\n $('#useful_item_submit').tooltip();\n });">. 
<false> is not true. 

답변

0

확실히 자바 스크립트 파일에 당신에게 자바 스크립트를 넣어 것입니다. public/javascripts/useful_item.js에,

def javascript(file) 
    content_for(:javascripts) { javascript_include_tag file } 
end 

다음 :

app/views/layouts/application.html.erb에 :

<%= yield :javascripts %> 

app/helpers/layout_helper.rb에서

나는이 정말 쉬운 자바 스크립트를 포함하도록 할

$(function(){ 
    $('#useful_item_submit').tooltip(); 
    // among other useful javascripts that useful_items might use 
}); 

및보기에서 :

관련 문제