سؤال

I'm trying to run minitest.
I followed a few videos on how to get it running, but none of them seem to get me around this message

Don't know how to build task 'minitest'

I think I must be missing a step or gem or something that the videos don't account for. But I don't have a clue what step that is..

Here's my gem file

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

My Rake file looks like this.

# 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

Test helper

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

And finally my test file

require 'test_helper'

class RepositoryTest < ActiveSupport::TestCase
  def setup
    @repo = Repository.new
  end

  def test_valid
    @repo.is_valie?
  end
end
هل كانت مفيدة؟

المحلول

Move minitest-rails out of the test group in your Gemfile. The rake tasks are defined in that gem and are not available because you aren't in the test environment when you run rake.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top