arempe93 / bunny-mock

A mock client for RabbitMQ modeled after the Bunny client in ruby
http://www.rubydoc.info/github/arempe93/bunny-mock
MIT License
44 stars 37 forks source link

Can bunny-mock be allowed to work with Bunny 1.7.x (and Ruby 1.9.3) #17

Open TimothyMDean opened 8 years ago

TimothyMDean commented 8 years ago

I'm trying to use bunny-mock to test some code that is stuck on Ruby 1.9.3 and Bunny 1.7.0 for a variety of reasons. Unfortunately for me, the current gemspec for bunny-mock specifies a minimum bunny version of 2.0 as well as Ruby language version 2.0.

Given that Bunny 2.0 is API compatible with Bunny 1.7 (see this link), it seemed reasonable that bunny-mock would work just fine with Bunny 1.7, unless of course bunny-mock makes use of Ruby 2.x-specific code.

I decided to try this out on a local clone of bunny-mock and so far (with a limited number of tests written) it has been working with no code changes. I've only had to change dependency versions in Gemfile and in bunny-mock.gemspec. My tests are far from thorough though.

Is there any interest in adding Bunny 1.7 support to the official releases of bunny-mock? If so I could try to do more thorough testing and issue a pull request. Or is retroactively adding support for really old versions not something that anyone else might need?

arempe93 commented 8 years ago

I think supporting Bunny 2.0 is a priority - but if you have a PR that allows support for older versions that doesn't tread on 2.0 support I would love to review it!

TimothyMDean commented 8 years ago

I am trying to get this change ready for a PR but I want to run your tests before submitting to make sure nothing has broken. Unfortunately I'm not terribly advanced when it comes to Rails so I'm having trouble getting the specs to run at all (let alone to test my change).

Can you please provide me some guidance on what I should need to do to run the bunny-mock tests?

arempe93 commented 8 years ago

Sure! All you have to do is run the command rake (which is like a ruby version of Makefile if you're more familiar with that). I set the default task to run the code linter and test suite.

Let me know if you have any other questions - I should probably add all this information to a contributing file evenutally

TimothyMDean commented 8 years ago

I've tried running the specs via rake, both explicitly and just using rake, and I get an error when I try to run. The same error happens whether I run under Ruby 1 or ruby 2. Here is the full stack trace of the error I get.

C:/jruby-1.7.25/bin/jruby.exe -I'C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec
-core-3.4.4/lib';'C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-support-3.4.1/
lib' 'C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3.4.4/exe/rspec' --pa
ttern 'spec/**/*_spec.rb'
Bundler::GemRequireError: There was an error while trying to load the gem 'bunny
'.
Gem Load Error is: wrong argument type Class (expected Module)
Backtrace for gem load error is:
org/jruby/RubyModule.java:2111:in `include'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/bunny-1.7.1/lib/bunny/jruby/socket.rb:
9:in `Socket'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/bunny-1.7.1/lib/bunny/jruby/socket.rb:
8:in `JRuby'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/bunny-1.7.1/lib/bunny/jruby/socket.rb:
4:in `Bunny'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/bunny-1.7.1/lib/bunny/jruby/socket.rb:
3:in `(root)'
org/jruby/RubyKernel.java:1040:in `require'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/bunny-1.7.1/lib/bunny/socket.rb:1:in `
(root)'
org/jruby/RubyKernel.java:1040:in `require'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/bunny-1.7.1/lib/bunny/socket.rb:3:in `
(root)'
org/jruby/RubyKernel.java:1040:in `require'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/bunny-1.7.1/lib/bunny.rb:1:in `(root)'

org/jruby/RubyArray.java:1613:in `each'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/bunny-1.7.1/lib/bunny.rb:12:in `(root)
'
org/jruby/RubyArray.java:1613:in `each'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/bundler-1.12.4/lib/bundler/runtime.rb:
1:in `(root)'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/bundler-1.12.4/lib/bundler/runtime.rb:
86:in `require'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/bundler-1.12.4/lib/bundler/runtime.rb:
81:in `require'
org/jruby/RubyKernel.java:1040:in `require'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/bundler-1.12.4/lib/bundler/runtime.rb:
70:in `require'
org/jruby/RubyArray.java:1613:in `each'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/bundler-1.12.4/lib/bundler.rb:102:in `
require'
C:/Users/tdean/RubymineProjects/bunny-mock/spec/spec_helper.rb:7:in `(root)'
org/jruby/RubyArray.java:1613:in `each'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3.4.4/lib/rspec/core/config
uration.rb:1:in `(root)'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3.4.4/lib/rspec/core/config
uration.rb:1295:in `requires='
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3.4.4/lib/rspec/core/config
uration.rb:1295:in `requires='
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3.4.4/lib/rspec/core/config
uration_options.rb:109:in `process_options_into'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3.4.4/lib/rspec/core/config
uration_options.rb:108:in `process_options_into'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3.4.4/lib/rspec/core/config
uration_options.rb:21:in `configure'
C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3.4.4/exe/rspec:4:in `(root
)'
Bundler Error Backtrace:

               require at C:/jruby-1.7.25/lib/ruby/gems/shared/gems/bundler-1.12
.4/lib/bundler/runtime.rb:90
                  each at org/jruby/RubyArray.java:1613
               require at C:/jruby-1.7.25/lib/ruby/gems/shared/gems/bundler-1.12
.4/lib/bundler/runtime.rb:81
                  each at org/jruby/RubyArray.java:1613
               require at C:/jruby-1.7.25/lib/ruby/gems/shared/gems/bundler-1.12
.4/lib/bundler/runtime.rb:70
               require at C:/jruby-1.7.25/lib/ruby/gems/shared/gems/bundler-1.12
.4/lib/bundler.rb:102
                (root) at C:/Users/tdean/RubymineProjects/bunny-mock/spec/spec_h
elper.rb:7
               require at org/jruby/RubyKernel.java:1040
                (root) at C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3
.4.4/lib/rspec/core/configuration.rb:1
                  each at org/jruby/RubyArray.java:1613
             requires= at C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3
.4.4/lib/rspec/core/configuration.rb:1295
             requires= at C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3
.4.4/lib/rspec/core/configuration.rb:1295
                  each at org/jruby/RubyArray.java:1613
  process_options_into at C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3
.4.4/lib/rspec/core/configuration_options.rb:109
  process_options_into at C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3
.4.4/lib/rspec/core/configuration_options.rb:108
             configure at C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3
.4.4/lib/rspec/core/configuration_options.rb:21
                 setup at C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3
.4.4/lib/rspec/core/runner.rb:105
                   run at C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3
.4.4/lib/rspec/core/runner.rb:92
                   run at C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3
.4.4/lib/rspec/core/runner.rb:78
                (root) at C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3
.4.4/exe/rspec:4
C:/jruby-1.7.25/bin/jruby.exe -I'C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec
-core-3.4.4/lib';'C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-support-3.4.1/
lib' 'C:/jruby-1.7.25/lib/ruby/gems/shared/gems/rspec-core-3.4.4/exe/rspec' --pa
ttern 'spec/**/*_spec.rb' failed
arempe93 commented 8 years ago

Hmmm....seems to me like trouble with JRuby and Bunny

see: https://github.com/ruby-amqp/bunny/issues/363

TimothyMDean commented 8 years ago

Well, that is really unfortunate. I am stuck with JRuby and Bunny for the time being. I did verify that I could make things work by going back to Bunny 1.7.0 rather than allowing 1.7.1 to be used. But that may not be much help for my situation.

Just out of curiosity, is there a reasonable way to add a run-time dependency to a gemspec that says "Use (version = 1.7.0) OR (version >= 2.0)" that would exclude version 1.7.1 and later 1.7.x releases?

arempe93 commented 8 years ago

Maybe doing some fancy gemspec magic like in the gemspec for onelogin/ruby-saml is the solution?

TimothyMDean commented 8 years ago

Thanks for the tip: I've used the same approach to set a dependency on bunny version 1.7.0 when running on the JRuby platform, and a dependency on 1.7 or later when not running on the JRuby platform. I will submit a pull request for this change in the not-too-distant future (my workplace's policy dictates that work done on company time can't be contributed back to open source projects without prior approval, so I just need to wait for that approval).