Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enqueue_at works in RSpec but not Cucumber step #103

Open
noreaster opened this issue Aug 7, 2014 · 7 comments
Open

Enqueue_at works in RSpec but not Cucumber step #103

noreaster opened this issue Aug 7, 2014 · 7 comments

Comments

@noreaster
Copy link

I'm not quite sure what I'm doing wrong. I can get enqueue_at to work in RSpec, but not cucumber.

Resque.enqueue works properly in cucumber (and RSpec) but I always get "Invalid argument - connect(2) (Errno::EINVAL)" when I try to run Resque.enqueue_at in cucumber

.env

require 'rubygems'
require 'spork'

Spork.prefork do
  require 'resque_spec/cucumber'
  require 'resque_spec/scheduler'
end

phone_poll_steps.rb (doesn't work)

When(/^It is time to be called$/) do

  PhonePollTaker.should have_schedule_size_of(0)
  Resque.enqueue_at(DateTime.now + 2.seconds, PhonePollTaker,  1) # line that fails
  PhonePollTaker.should have_schedule_size_of(1)
end

phone_poll_spec.rb (works)

describe PhonePoll do
  it 'should be able to make a call' do
    ...
    PhonePollTaker.should have_schedule_size_of(0)
    Resque.enqueue_at(DateTime.now + 2.seconds, PhonePollTaker,  1)
    PhonePollTaker.should have_schedule_size_of(1)
  end
end

Works in both

  Resque.enqueue(PhonePollTaker,  1)
@leshill
Copy link
Owner

leshill commented Aug 10, 2014

Hi @noreaster,

No idea. Here are some suggestions:

The error message makes me think that you are running in a different environment. Do you have any invocations of ResqueSpec.disable_ext = true?

Another cause may be due to the prefork. If Resque is loaded afterwards, the hooks will not have been set correctly by ResqueSpec. The way to debug this is to stop inside [https://github.com/leshill/resque_spec/blob/master/lib/resque_spec/scheduler.rb#L19] and verify that you have ResqueSpec hooked up.

A failing example would be great.

@noreaster
Copy link
Author

I've tried putting the requires inside and outside of the prefork and it doesn't make a difference. It is loading up the resque-scheduler rather than resque_spec for enqueue_at. However it does load up resque_spec for enqueue.

I'll try to boil down the issue into a separate example instance and post it when I sort that out.

@noreaster
Copy link
Author

Here's an instance of how I had it set up. https://github.com/noreaster/resque_spec_example
Is there somewhere I have the configuration wrong?

The examples are:
/spec/models/phone_poll_spec.rb and
/features/phone_polls/test_case.feature

I was using guard to test if that makes a difference

@leshill
Copy link
Owner

leshill commented Aug 12, 2014

Hi @noreaster,

Thanks for the example, the only thing I can suggest is to move the require 'resque_spec/scheduler' to the each_run block? I will run it myself when I have some free time later this week.

@noreaster
Copy link
Author

No worries, unfortunately that doesn't seem to solve the issue. It's probably a configuration issue, but I just don't know where it would be.

@leshill
Copy link
Owner

leshill commented Aug 14, 2014

Hi @noreaster,

That last message was confusing :) — you are still having the problem?

@noreaster
Copy link
Author

Whoops, learning how to type is important. I meant that it's still a problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants