2017-05-09 47 views
0

我收到'有'方法未定義的方法錯誤消息。未定義的方法'有'爲#<對象:0x007f997fabf778>(NoMethodError)

expect(@gymhomepage.find_your_local_gym).to have(@gymhomepage.find_your_local_gym.first_gym_location)

我想如果斷言CSS first_gym_location位於find_your_local_gym部分中。

Please see my framework on Github

沒有任何人有什麼建議嗎?

+0

沒有人會去讀你的整個項目在Github上,你的問題需要是自己的-contained。 –

回答

1

水豚不提供have匹配器,它提供了一堆have_<something>匹配器。假設@gymhomepage.find_your_local_gym.first_gym_location返回一個CSS選擇器,那麼你會使用

expect(@gymhomepage.find_your_local_gym).to have_css(@gymhomepage.find_your_local_gym.first_gym_location) 

相反,如果@gymhomepage.find_your_local_gym.first_gym_location是發現元素已經作用域,你只需要做

expect(@gymhomepage.find_your_local_gym.first_gym_location).to be 

因爲它已經保證先限定的方法通過調用它到find_your_local_gym元素(假設你還沒有陷入XPath陷阱 - https://github.com/teamcapybara/capybara#beware-the-xpath--trap

+0

Whalpole多數民衆贊成在工作。謝謝。 –

相關問題