starting rails in test environment

前端 未结 3 744
野性不改
野性不改 2021-02-06 02:47

I\'m trying to load up rails in the test environment using a ruby script. I\'ve tried googling a bit and found this recommendation:

require \"../../config/enviro         


        
3条回答
  •  梦毁少年i
    2021-02-06 03:31

    You know you can run your unit, functional and integration tests from Rake, right ? Check out the output of rake -T test to see how.

    In case you need something more custom, you can create your own Rake task. Put something like this in a file in lib/tasks:

    namespace :custom_tests do
      desc "Run my custom tests"
      task :run => :environment do
        puts "RAILS_ENV is #{RAILS_ENV}"
        system "execute mysql script here"
        # Do whatever you need to do
      end
    end
    

    The => :environment loads the current environment for you. Then, you can run your task in the test environment like this: RAILS_ENV=test rake custom_tests:run

提交回复
热议问题