I have a Resque job that I am trying to test using rspec. The job looks something like:
class ImporterJob
def perform
job_key = options['test_key']
user = options['user']
end
I am using Resque status so I am using the create method to create the job like so:
ImporterJob.create({key:'test_key',user: 2})
If I try to create a job the same way in an rspec test, the options appear to not be making it to the job. As in, when I insert a binding.pry after user = options['user']
, the options hash is empty.
My rspec test looks like this:
describe ImporterJob do
context 'create' do
let(:import_options) {
{
'import_key' => 'test_key',
'user' => 1,
'model' => 'Test',
'another_flag' => nil
}
}
before(:all) do
Resque.redis.set('test_key',csv_file_location('data.csv'))
end
it 'validates and imports csv data' do
ImporterJob.create(import_options)
end
end
end