如何解决警惕不要执行水豚测试的规格/功能
我的防护文件经过编辑以执行写在规范/功能中的测试用例,因此,如果控制器或模型内部发生任何更改,它将执行所有规范/功能测试:
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { "spec/features" } ## any change made in controller it will run all tests under specs/features
watch(%r{^app/models/(.+)\.rb$}) { "spec/features" } ## any change made in model it will run all tests under specs/features
添加了必需的gemfile
group :development,:test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug',platforms: [:mri,:mingw,:x64_mingw]
gem 'rspec-rails','~> 3.8.3'
gem 'faker','~> 2.13.0'
gem 'rubocop-faker'
gem 'guard','~> 2.16.2' ## To automatialy run test cases
gem 'guard-rspec','~> 4.7.3'
gem 'guard-cucumber'
gem 'capybara','~> 3.32.2'
end
我的文件为:
require 'rails_helper'
RSpec.feature "Create Article" do
scenario "A user create a new article" do
visit "/"
click.link 'New Article'
fill_in :Title,with: Faker::Book.title
fill_in :Body,with: Faker::Lorem.paragraph_by_chars(number: 256)
click_button 'Create Article'
assert page.has_content? "Article was successfully created"
# expect(:page).to have_content("Article was successfully created")
# expect(page.current_path).to eq('/articles/*')
assert page.current_path.match(/articles\/*/)
end
end
但是在运行警卫队时,它不会检测到任何书面测试用例并给出以下结果:
17:42:01 - INFO - Running: spec/features
No examples found.
Finished in 0.00035 seconds (files took 0.10616 seconds to load)
0 examples,0 failures
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。