大佬教程收集整理的这篇文章主要介绍了ruby-on-rails – RSpec / Capybara测试has_selector难题,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经阅读了用户的解决方法并知道有不同的方法来编写测试以使其工作但我想使用have_SELEctor来保持代码的一致性.任何解释/建议都会非常有帮助.
我不明白为什么下面的测试通过了h1元素而不是title元素:
spec.rb:
describe "Static pages" do describe "Home page" do it "should have the h1 'Sample App'" do visit '/static_pages/home' expect(pagE).to have_SELEctor('h1',:text => 'Sample App') end it "should have the title 'Home'" do visit '/static_pages/home' expect(pagE).to have_SELEctor('title',:text => "Ruby on Rails Tutorial Sample App | Home") end end
home.html的:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Ruby on Rails Tutorial Sample App | Home</title> </head> <body> <h1>Sample App</h1> </body> </html>
以上是大佬教程为你收集整理的ruby-on-rails – RSpec / Capybara测试has_selector难题全部内容,希望文章能够帮你解决ruby-on-rails – RSpec / Capybara测试has_selector难题所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。