2017-03-13 49 views
0

我使用MINITEST,水豚和騷靈,這是simple_form測試:水豚和click_on方法+ simple_form [JavaScript錯誤]

<%= simple_form_for :search, url: ads_path , wrapper: :inline_form, html: {class: 'form-inline'}, :method => :get do |f| %> 
    <%= f.error_notification %> 
    <%= f.input :type_id, collection: @types, label_html: {class: 'form_home'}, selected: 'house'%> 
    <%= f.input :city, label: 'Where?', placeholder: 'What is the city ?'%> 
    <br> 
    <br> 
    <%= f.submit "Search", :class => "btn btn-primary btn-xl page-scroll" %> 
<% end %> 

的問題,當我添加click_on「搜索」依賴

test "search correctly" do 
    visit "/" 
    select "house", :from => "search_type_id" 
    fill_in 'search_city' , with: "" 
    click_on 'Search' 
    end 

在終端上的javascrip錯誤:

Capybara::Poltergeist::JavascriptError:
Capybara::Poltergeist::JavascriptError: One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details).

Error: Bounds are not valid. 
    Error: Bounds are not valid. 
     at http://127.0.0.1:43411/assets/application-1442915127e4fa1072f69aa9aa4d07ce85cdc5115df9b3a40da528ee05ebfe94.js:43537 
     at http://127.0.0.1:43411/ads?utf8=%E2%9C%93&search%5Btype_id%5D=1&search%5Bcity%5D=&commit=Search:135 
     test/integration/home_test.rb:16:in `block in <class:HomeTest>' 

還有其他的選擇嗎?

回答

0

您有兩個選擇,修復您的JS或禁用錯誤消息中提到的JS錯誤報告。

要解決您的JS要麼通過查看組合的JS行43537看到爲什麼它的日誌記錄「邊界無效」或在開發模式中執行相同的行爲以找出哪個單獨的JS文件產生錯誤並開始從那裏調試。

如果你不在乎固定錯誤的原因。另一方面(你應該關心它雖然),那麼你可以配置你的驅動程序不

Capybara.register_driver :poltergeist do |app| 
    Capybara::Poltergeist::Driver.new(app, js_errors: false) 
end 

報告JS錯誤,提到在Poltergeist自述 - https://github.com/teampoltergeist/poltergeist#customization

+0

謝謝你的回答,併爲延誤抱歉。我嘗試了你的悲傷,無法解決這個問題,但我決定去Rspec,而不是其他原因!現在我進行得很順利;) –