我知道以前有人问过同样的问题,但这些情况与我的完全不同。我的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'