Giter Site home page Giter Site logo

Comments (11)

philostler avatar philostler commented on July 30, 2024

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

from rspec-sidekiq.

hughkelsey avatar hughkelsey commented on July 30, 2024

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.

from rspec-sidekiq.

philostler avatar philostler commented on July 30, 2024

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

from rspec-sidekiq.

hughkelsey avatar hughkelsey commented on July 30, 2024

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.

from rspec-sidekiq.

philostler avatar philostler commented on July 30, 2024

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

from rspec-sidekiq.

hughkelsey avatar hughkelsey commented on July 30, 2024

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.

from rspec-sidekiq.

philostler avatar philostler commented on July 30, 2024

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

from rspec-sidekiq.

philostler avatar philostler commented on July 30, 2024

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

from rspec-sidekiq.

hughkelsey avatar hughkelsey commented on July 30, 2024

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

from rspec-sidekiq.

fduperier avatar fduperier commented on July 30, 2024

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'

from rspec-sidekiq.

philostler avatar philostler commented on July 30, 2024

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.

from rspec-sidekiq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.