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

undefined method `raw_push' #12

Closed
hughkelsey opened this issue May 2, 2013 · 11 comments
Closed

undefined method `raw_push' #12

hughkelsey opened this issue May 2, 2013 · 11 comments

Comments

@hughkelsey
Copy link

I'm on Rails 4.0 RC1 with sidekiq 2.11.2 and rspec 2.13.1

When I include the gem:

group :test do
gem "rspec-sidekiq"
end

Rspec won't start and returns:
..../sidekiq-2.11.2/lib/sidekiq/testing.rb:5:in alias_method': undefined methodraw_push' for class `Class' (NameError)

I have not included rspec-sidekiq or sidekiq/testing in my spec_helper. Any Ideas?

@philostler
Copy link
Collaborator

That's a new one on me.

I'd try rolling out rspec-sidekiq and just adding require "sidekiq/testing" into your spec_helper.rb and see if it's the vanilla Sidekiq testing class that's causing problems

@hughkelsey
Copy link
Author

Unfortunately that's not it, rspec runs with either require 'sidekiq/testing' or require 'sidekiq/testing/inline'. In both cases I get undefined method has_enqueued_job? which is totally expected as rspec-sidekiq isn't installed. I am doing this within an engine which may be an issue. I'll try in a clean app and see.

@philostler
Copy link
Collaborator

OK cheers, let me know if that's it. I'll take a look when I get time to see if something has broken the gem in the latest version of Sidekiq

@hughkelsey
Copy link
Author

Well now I'm stumped! A new Rails 4RC1 app, SideKiq, Rspec and Rspec-SideKiq all work fine.

I went back to my engine where I have add_dependency "sidekiq", "~> 2.11.2" in my gemspec, and moved it to gem 'sidekiq' in the Gemfile, bundling and voila the specs pass without errors. Moving it back, bundling and I get the same error as before.

I also went though removing a bunch of other gems like Spork and Cucumber to isolate the issue but they seamed to have no effect.

@philostler
Copy link
Collaborator

I've not taken a further look at this yet... you had chance to dive any deeper?

@hughkelsey
Copy link
Author

I haven't investigated past the fact that it works with Sidekiq in the Gemfile but not in the Gemspec. My only guess is something additional needs to be required somewhere as a result but I don't know Sidekiq well enough to know what.

@philostler
Copy link
Collaborator

Do you have a dummy project setup where I can quick reproduce this?

@philostler
Copy link
Collaborator

Scratch that, I managed to reproduce this while testing the gem itself. It's simply that Sidekiq needs to be required somewhere (whether that's by Bundler or require sidekiq).

When adding a dependency in the gemspec Bundler does not require it for you so you must do that yourself (in my case in the spec_helper.rb).

There's a Stack Overflow thread here about it.... http://stackoverflow.com/questions/15721474/how-do-i-get-rspec-to-read-the-dependencies-in-my-gemspec

@hughkelsey
Copy link
Author

Figured out the same thing myself in putting together a sample app. Thanks for the help and interest, great project!

@fduperier
Copy link

Hi,

I have the same problem and cannot manage to resolve it.
I am on ruby 2.0.0 (and tested with 1.9.3), running sidekiq (2.13.0) with rspec-sidekiq (0.4.0) and rspec-rails (2.14.0).
The error message is : sidekiq-2.13.0/lib/sidekiq/testing.rb:7:in 'alias_method': undefined method 'raw_push' for class 'Class' (NameError)

Gemfile :
group :test do
gem 'rspec-rails'
gem 'rspec-sidekiq'
end

spec_helper.rb :
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'sidekiq'
require 'sidekiq/testing'
require 'rspec/rails'
require 'rspec/autorun'

@philostler
Copy link
Collaborator

This must be the same issue as has been discussed in this thread already (Sidekiq not being required properly).

I primarily use a Sinatra setup so within my spec_helper.rb I have this...

require "bundler"
Bundler.require(:default, ENV["RACK_ENV"].to_sym)

...to perform my requires for me.

The only thing I can think of off the top of my head is ensure that you require sidekiq before rspec-sidekiq is required.

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