1

我在测试方面是全新的,经过两年的 Rails 开发,它必须改变!

因此,我试图在 rails 4 应用程序上安装 minitest。

我做了以下事情:

更新了我的 gemfile:

group :test do
  gem 'factory_girl'
  gem 'minitest-rails'
  gem 'minitest-rails-capybara'
  gem 'minitest-colorize'
  gem 'minitest-focus'
  gem "shoulda-matchers"
  gem "guard-rspec"
end

在 test/test_helper.rb 中创建了一个助手

ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "rails/test_help"
#require "minitest/rails"
require "minitest/spec"
require 'minitest/focus'

# To add Capybara feature tests add `gem "minitest-rails-capybara"`
# to the test group in the Gemfile and uncomment the following:
 require "minitest/rails/capybara"

# Uncomment for awesome colorful output
 require "minitest/pride"

class ActiveSupport::TestCase
  # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
  ActiveRecord::Migration.check_pending!
  fixtures :all
  extend MiniTest::Spec::DSL

  #use ActiveSupport::TestCase when describing an ActiveRecord model
  register_spec_type self do |desc|
      desc < ActiveRecord::Base if desc.is_a? Class
  end

  # Add more helper methods to be used by all tests here...
  def self.prepare
     # Add code that needs to be executed before test suite start
   end
   prepare

   def setup
     # Add code that need to be executed before each test
   end

   def teardown
     # Add code that need to be executed after each test
   end

end

生成了一个具有一些“测试”测试文件的脚手架,例如:

模型/project_test.rb

require "test_helper"

describe Project do
  before do
    @project = Project.new
  end

  it "must be valid" do
    @project.valid?.must_equal true
  end
end

当我在终端输入 rake minitest:models 时,这就是我得到的:

Run options: --seed 40421

# Running tests:



Fabulous tests in 0.049207s, 0.0000 tests/s, 0.0000 assertions/s.

0 tests, 0 assertions, 0 failures, 0 errors, 0 skips

显然, minitest 运行但我的测试没有执行。怎么了?

谢谢!!!

4

1 回答 1

0

该问题是由于与 rspec 冲突造成的,该冲突是由 guard-rspec 作为依赖项添加的。

非常感谢@blowmage!

于 2013-10-24T05:04:25.083 回答