使用与续集轨道的固定装置

时间:2015-11-11 20:23:09

标签: ruby-on-rails ruby fixtures sequel

我正在使用现有的Rails 4.0项目,该项目使用Sequel作为ORM,而不是通过sequel-rails gem使用ActiveRecord。目前没有针对此应用程序的测试。我正在尝试编写一些测试来加载YAML文件中的灯具类似于Rails指南推荐的(http://guides.rubyonrails.org/testing.html#the-low-down-on-fixtures)。到目前为止,我还没有成功地试图加装灯具。是否有任何使用Sequel测试Rails应用程序的建议或指南?

我找到了Jeremy Evans的一颗宝石,fixture_dependencies(https://github.com/jeremyevans/fixture_dependencies),这似乎很有希望。它宣称它适用于Sequel和ActiveRecord,但在调用fixtures类方法时出现错误。

这是我的设置:

  1. config/application.rb中,我已将ActiveRecord禁用为sequel-rails github页面概述:

    #require 'rails/all'
    require 'action_controller/railtie'
    #require 'active_record/railtie'
    require 'action_mailer/railtie'
    require 'rails/test_unit/railtie'
    require 'sprockets/railtie'
    
  2. test/test_helper.rb中,我需要fixture_dependencies

    ENV["RAILS_ENV"] ||= "test"
    require File.expand_path('../../config/environment', __FILE__)
    require 'rails/test_help'
    require 'fixture_dependencies/test_unit/sequel'
    
    require 'minitest/focus'
    require 'minitest/reporters'
    
    Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new
    
    class ActiveSupport::TestCase
      # Disabling the following since we are not using ActiveRecord
      #ActiveRecord::Migration.check_pending!
    
      fixtures :all
    
    end
    
  3. 当我运行测试时,出现以下错误:

    ➜ bundle exec rake
    rake aborted!
    undefined method `fixtures` for ActiveSupport::TestCase:Class
    

0 个答案:

没有答案