
运行Rake测试似乎没有进行我的功能测试.我在文件中有一个测试,运行rake测试不会改变断言的数量.当我运行rake测试时,跳过测试也不会显示.
这是存储库的链接:https://github.com/rrgayhart/rails_template
以下是我遵循的步骤
>我将此添加到Gemfile并运行bundle
group :development,:test do gem 'capybara' gem 'capybara_minitest_spec' gem 'launchy'end
>我将此添加到test_helper
require 'capybara/rails'
>我创建了一个文件夹测试/功能
>我创建了一个名为drink_creation_test.rb的文件
>以下是该功能测试文件的代码
require 'test_helper'class DrinkCreationTest < MiniTest::Unit::TestCase def test_it_creates_an_drink_with_a_Title_and_body visit drinks_path click_on 'new-drink' fill_in 'name',:with => "PBR" fill_in 'description',:with => "This is a great beer." fill_in 'price',:with => 7.99 fill_in 'category_ID',:with => 1 click_on 'save-drink' within('#Title') do assert page.has_content?("PBR") end within('#description') do assert page.has_content?("td",text: "This is a great beer") end endend 我想我没有正确连接的问题.
如果我还能提供其他任何可能有助于诊断此问题的信息,请告知我们.
由于您使用的是capybara_minitest_spec,因此您需要将Capybara :: DSL和Capybara :: RSpecMatchers包含在您的测试中.并且因为您在此测试中未使用ActiveSupport :: TestCase或其他Rails测试类,您可能会在数据库中看到不一致,因为此测试在标准rails测试事务之外执行.
require 'test_helper'class DrinkCreationTest < MiniTest::Unit::TestCase include Capybara::DSL include Capybara::RSpecMatchers def test_it_creates_an_drink_with_a_Title_and_body visit drinks_path click_on 'new-drink' fill_in 'name',text: "This is a great beer") end endend
或者,您可以使用minitest-rails和minitest-rails-capybara生成并运行这些测试.
$rails generate mini_test:feature DrinkCreation$rake minitest:features总结
以上是内存溢出为你收集整理的ruby-on-rails – 耙子测试没有在最小的时候进行水豚测试全部内容,希望文章能够帮你解决ruby-on-rails – 耙子测试没有在最小的时候进行水豚测试所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)