我试图运行minitest 我关注了一些关于如何让它运行的视频,但它们似乎都没有让我知道这个消息
不知道如何建立任务' minitest'
我想我必须错过一个步骤或宝石或视频不能解释的东西。 但我不知道那是什么步骤..
这是我的宝石文件
source 'https://rubygems.org'
ruby '1.9.3'
gem 'rails', '4.0.0'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
gem 'bootstrap-sass'
gem 'devise'
gem 'haml-rails'
gem 'pg'
group :development do
gem 'better_errors'
gem 'binding_of_caller', :platforms=>[:mri_19, :mri_20, :rbx]
gem 'guard-bundler'
gem 'guard-rails'
gem 'html2haml'
gem 'hub', :require=>nil
gem 'quiet_assets'
gem 'rails_layout'
gem 'rb-fchange', :require=>false
gem 'rb-fsevent', :require=>false
gem 'rb-inotify', :require=>false
end
group :production do
gem 'unicorn'
end
group :test do
gem 'capybara'
gem 'minitest-spec-rails'
gem 'minitest-wscolor'
gem 'minitest-rails'
end
我的Rake文件看起来像这样。
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
ComCon::Application.load_tasks
测试助手
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "rails/test_help"
require "minitest/rails"
# 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.
fixtures :all
# Add more helper methods to be used by all tests here...
end
最后是我的测试文件
require 'test_helper'
class RepositoryTest < ActiveSupport::TestCase
def setup
@repo = Repository.new
end
def test_valid
@repo.is_valie?
end
end
答案 0 :(得分:3)
将minitest-rails
移出Gemfile中的test
组。 rake任务在gem中定义,因为当你运行rake
时你不在测试环境中,所以不可用。