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

Issues with ResqueSpec.reset! while using spork #69

Open
Blue-Dog-Archolite opened this issue Apr 17, 2013 · 8 comments
Open

Issues with ResqueSpec.reset! while using spork #69

Blue-Dog-Archolite opened this issue Apr 17, 2013 · 8 comments

Comments

@Blue-Dog-Archolite
Copy link

I am using spork and including ResqueSpec.reset! in Spork.each_run block

Spork.each_run do
  require 'resque_spec'
  ResqueSpec.reset!
end

However in the rspec tests, i am still getting failures due to the system not being able to connect to the Redis server. I have also attempted to use it by sticking it in before(:each)

require 'spec_helper'
describe Order do
  before(:each) do
    <some boring setup>
    ResqueSpec.reset!
    @order = FactoryGirl.create(:order)
  end
  it "makes an order" do
    @order.should be_valid
  end
end

Failure/Error: @order = FactoryGirl.create(:order)
Redis::CannotConnectError:
Error connecting to Redis on localhost:6379 (ECONNREFUSED)

Suggestions?

@leshill
Copy link
Owner

leshill commented Apr 18, 2013

Hi @Blue-Dog-Archolite,

If you see errors about failed connections to Redis, it is most likely that you are using a plugin. Resque plugins are usually (pre 2.0) written fairly loosely and often just reach directly into Redis to manipulate data, some their own, and some Resque's. This is neither good nor bad, just reality.

If you are using a plugin and can see an easy way to mock it, please open a PR and I will add it to resque_spec.

Ideally in 2.0, every plugin provides some implementation for tests and some simple assertions. For example the resque_scheduler mock in resque_spec allows for asserting that something was scheduled but no way to do a run of the scheduler.

/cc @steveklabnik

@steveklabnik
Copy link

Yup.

Though if you're getting an ECONNREFUSED it seems more serious. Are you sure you have a Redis running?

@Blue-Dog-Archolite
Copy link
Author

I wanted to be able to run the tests without having to have a Redis instance running.

@steveklabnik
Copy link

It's not going to be fully possible, because Resque forks, you need a connection to an actual sever. 12 of our tests require a real one, even if the rest don't.

@Blue-Dog-Archolite
Copy link
Author

Interesting. Glad I asked before I spent a week going down a hole that doesn't have an end Thanks for the feedback. Gem works with Redis server running.

@steveklabnik
Copy link

Yeah, I'm super bummed about it, and it's something that I'm working on.

@Blue-Dog-Archolite
Copy link
Author

I hacked it a bit. It needs some tests but this would work. All my test pass without a redis-server running.

Also, it injects the requests to the specified queues.

Blue-Dog-Archolite@d17ea84

@leshill
Copy link
Owner

leshill commented May 2, 2013

Hi @Blue-Dog-Archolite,

Sorry it took so long to take a look at this, but did you follow the instructions in the README for resque-scheduler?

A cursory look and your commit seems to be doing the same thing resque_spec is doing?

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

3 participants