2017-07-24 39 views
0

我的Rails 5.1,並使用默認的系統測試測試類型錯誤與水豚assert_text的Rails 5.1

我在一類RetreatTest下面的代碼:

test "Create a new Retreat" do 
    visit retreats_url 

    click_on 'Create a new Retreat' 

    fill_in "Title", with: "Retreat Title" 
    fill_in "Tagline", with: "Retreat tagline" 
    select('Individual', from: 'Type') 

    fill_in "Description", with: "Retreat Description" 
    attach_file('Image', Rails.root.join('test', 'images', 'test-1.jpg')) 

    click_on "Submit" 

    assert_text("Retreat was successfully saved.") 
end 

我不明白爲什麼如果我寫的,而不是assert find('.alert').has_content?('Retreat was successfully saved.')所有assert_text我的測試中通過

Error: 
RetreatsTest#test_Create_a_new_Retreat: 
TypeError: exception class/object expected 
test/system/retreats_test.rb:36:in `block in <class:RetreatsTest>' 

:我不斷收到此錯誤。

有人可以幫助我嗎?

編輯1: 在與回溯選項運行測試,我得到如下:

Error: 
    RetreatsTest#test_Create_a_new_Retreat: 
    TypeError: exception class/object expected 
    /Users/dhaliman/.rvm/gems/ruby-2.3.1/gems/capybara-2.14.2/lib/capybara/minitest.rb:52:in `raise' 
    /Users/dhaliman/.rvm/gems/ruby-2.3.1/gems/capybara-2.14.2/lib/capybara/minitest.rb:52:in `rescue in assert_text' 
    /Users/dhaliman/.rvm/gems/ruby-2.3.1/gems/capybara-2.14.2/lib/capybara/minitest.rb:48:in `assert_text' 
    /Users/dhaliman/Code/Workspace AVR WebApp/avr/test/system/retreats_test.rb:36:in `block in <class:RetreatsTest>' 
+0

您是否有更多的錯誤堆棧跟蹤,所以我們可以看到哪個版本的'assert_text'被調用? –

+0

如何在系統測試中做堆棧跟蹤?任何想法? – dhaliman

+0

由於這是一個錯誤而不是測試失敗異常,因此您可以嘗試使用:verbose或:backtrace選項運行測試 - 'rails test -b test' –

回答

1

升級到您目前使用2.14.2並且有最新的水豚(2.14.4)對於迷你測試2.14.3中的修復斷言應該修復不正確的錯誤,並讓它返回正確的錯誤(即它找不到文本)