Search code examples
ruby-on-railsrubyruby-on-rails-4rspecresque

How to switch Resque environment from development to test?


I'm very new to rails and recently I'm trying to use Resque and Rspec to test my codes. What I'm stocked with is to change Resque environment to test.

This is my state:

  1. Redis-server is lunched: port 6379, PID: 6046
  2. resque-web is lunched:

    $ resque-web
    [2014-09-19 21:52:43 +0430] Starting 'resque-web'...
    [2014-09-19 21:52:43 +0430] trying port 5678...
    Couldn't get a file descriptor referring to the console</li>
    

Now I can see resque web console at http://0.0.0.0:5678/stats/resque

Well, on Stats tab, there's a table and at the first row, environment is set to development.

  • Resque Client connected to redis://127.0.0.1:6379/0
  • environment development
  • failed 0
  • pending 0
  • processed 37780
  • queues 0
  • servers ["redis://127.0.0.1:6379/0"]
  • workers 0
  • working 0

I want to set Resque environment to test, so that I test jobs created by my rspec tests using test database, but I don't know how.Any tips?


Solution

  • Try to set the RAILS_ENV environment variable before running resque-web, e.g.

    $ RAILS_ENV=test resque-web