Rails unit testing doesn't load fixtures

后端 未结 6 1110
梦谈多话
梦谈多话 2020-12-16 01:54

rake test:units fails in my current application, because the needed data of the fixtures is missing.

If I\'m loading the fixtures manually via rak

6条回答
  •  余生分开走
    2020-12-16 02:30

    Put the call to fixtures :all in your test class, not the super class (test_helper). My guess is that initialization of the super class isn't working the way you're expecting and that fixtures :all isn't be called. Perhaps try putting the call in the initialize method of test_helper.

    My test/test_helper.rb looks like this:

    ENV['RAILS_ENV'] ||= 'test'
    require File.expand_path('../../config/environment', __FILE__)
    require 'rails/test_help'
    
    class ActiveSupport::TestCase
      # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
      fixtures :all
    
      # Add more helper methods to be used by all tests here...
    end
    

提交回复
热议问题