【问题标题】:Don't know how to build task 'recipe_test.rb'不知道如何构建任务'recipe_test.rb'
【发布时间】:2016-01-20 22:57:06
【问题描述】:

我知道之前有人问过同样的问题,但这些情况与我的完全不同。我的rails_app/test/integration 中有一个.rb 文件

recipe_test.rb

require "test_helper"

class RecipeFlowsTest < ActionDispatch::IntegrationTest
  fixtures :recipes
  test 'create recipes' do
    https! # sign in emulation
    curry = recipes(:curry)
    get '/recipes/new'
    assert_response :success

    post_via_redirect '/recipes/new', title: recipes(:curry).title
    assert_equal '/recipes', path
    assert_equal 'Create Recipe', flash[:notice]

    https!(false) # sign out emulation
    get '/recipes'
    assert_response :success
    assert assigns(:recipes) # fetch out inst var :recipes (in controller)
  end
end

还有一个test/fixture/recipe_test.yml

curry:
  title: Curry
  food_preference_id: 1
  food_type: 1
  cuisine_id: 1
  servings: 1
  cooking_time: 1
  level_of_difficulty: Easy
  ingredients: Onions Tomatoes Salt Oil
  procedure: Heat Oil Chop Onions,
             tomatoes and Salt to it.

这是我的test/helper_test.rb

ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'

class ActiveSupport::TestCase
integration tests
  fixtures :all
end

现在当我做rake test recipe_test.rb --trace

它给了我以下错误

** Invoke test (first_time)
** Execute test
** Invoke test:run (first_time)
** Execute test:run
rake aborted!
Don't know how to build task 'recipe_test.rb'

【问题讨论】:

    标签: ruby-on-rails rake-task rakefile rake-test


    【解决方案1】:

    您的rake 任务无效。 Here's a list of proper rake test tasks.

    你只需要

    rake test
    

    为你的recipe_test,你也可以做rake test:integration

    【讨论】:

    • Eeeeeeeeeeh,因为我在 rake 上的研发薄弱,浪费了 4 个小时。
    • 非常感谢朋友!
    猜你喜欢
    • 2013-02-01
    • 2014-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-24
    • 2018-07-13
    相关资源
    最近更新 更多