1

私はテストの初心者で、2 年間の Rails 開発の後、変更する必要があります。

したがって、レール 4 アプリケーションに minitest をインストールしようとしています。

私は次のことをしました:

私の宝石ファイルを更新しました:

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

次のようないくつかの「テスト」テストファイルを含む足場を生成しました。

models/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

どうやらミニテストは実行されますが、私のテストは実行されません。どうしたの?

ありがとう!!!

4

1 に答える 1

0

この問題は、guard-rspec によって依存関係として追加された rspec との競合が原因でした。

@blowmage に感謝します!

于 2013-10-24T05:04:25.083 に答える