1

以前に同じ質問がされたことは知っていますが、それらは私のものとはまったく異なるシナリオでした。私のrecipe_test.rb.rbにファイルがありますrails_app/test/integration

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'
4

1 に答える 1

4

あなたのrakeタスクは無効です。以下は、適切なレーキ テスト タスクのリストです

あなただけが必要です

rake test

あなたのためにrecipe_test、あなたもできるrake test:integration

于 2015-10-21T19:54:02.680 に答える