大佬教程收集整理的这篇文章主要介绍了Capybara / RSpec’has_css’匹配器不工作,但has_css,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
require 'spec_Helper' feature 'View the homepage' do scenario 'user sees relevant page title' do visit root_path expect(pagE).to have_css('title',text: "Todo") end end
失败的消息是:@H_616_5@
1) View the homepage user sees relevant page title Failure/Error: expect(pagE).to have_css('title',text: "Todo") Capybara::ExpectationNotMet: expected to find css "title" with text "Todo" but there were no matches. Also found "",which matched the SELEctor but not all filters.
标题元素和正确的文本在渲染页面上@H_616_5@
但是当我在功能规格中更改这一行时:@H_616_5@
expect(pagE).to have_css('title',text: "Todo")
到这个:@H_616_5@
page.has_css?('title',text: "Todo")
然后测试通过. [编辑 – 但是从@JusTinKo看到这个测试不是一个很好的测试,因为它总是会通过]@H_616_5@
如何获得has_css(…)表单的工作?是配置问题吗?@H_616_5@
这是我的Gemfile的相关部分:@H_616_5@
group :development,:test do gem 'rspec-rails' gem 'capybara' end
而我的spec / spec_Helper.rb设置如下:@H_616_5@
ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment",__FILE__) require 'rspec/rails' require 'rspec/autorun' require 'capybara/rails' require 'capybara/rspec' Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } RSpec.configure do |config| # out of the box rspec config code ommitted config.include Capybara::DSL end
任何人知道我可能做错了什么?@H_616_5@
以上是大佬教程为你收集整理的Capybara / RSpec’has_css’匹配器不工作,但has_css全部内容,希望文章能够帮你解决Capybara / RSpec’has_css’匹配器不工作,但has_css所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。