I know same question is asked before but those were totally different scenarios than mine . I have a .rb
file in my rails_app/test/integration
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
And a 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.
Here is my 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
Now when i do rake test recipe_test.rb --trace
It give me following error
** 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'
Your rake
task is invalid. Here's a list of proper rake test tasks.
You just need
rake test
For your recipe_test
, you can also do rake test:integration