The conflict about both requiring garb and right_http_connection

When I ran spec in a rails project, rspec printed following line:

undefined method 'eql' for :page_path:Symbol

I know the garb gem has some extention codes for Symbol in lib/garb/support.rb file. I used command

 find /Library/Ruby/Gems/1.8/gems/ -name "*.rb" -print | xargs grep '\<support\>' | grep  'require' 

to find files that contain codes require 'support'. In your computer, you should change the path "/Library/Ruby/Gems/1.8/gems/" to your gem installed dir.

/Library/Ruby/Gems/1.8/gems/garb-0.7.6/lib/garb.rb:require 'support'
/Library/Ruby/Gems/1.8/gems/right_http_connection-1.3.0/lib/right_http_connection.rb:require 'support'

So I guess right_http_connection and garb both require 'support' will cause one of them not to be required. I wrote some test codes to verify my judgment. First, unpack these gems needed to be tested.

gem unpack garb -v '0.7.6'
gem unpack right_http_connection -v '1.3.0'

Then I changed garb-0.7.6/lib/garb.rb:line 23 from

    require 'support'


    if require 'support'
      puts 'garb support has loaded'
      puts 'garb support has not loaded'

Then I created two spec files: garb_rhc_spec.rb and rhc_garb_spec.rb.

garb_rhc_spec.rb's contents:

    require 'spec'
    require 'garb-0.7.6/lib/garb'
    require 'right_http_connection-1.3.0/lib/right_http_connection'

    describe 'first require garb, then require right_http_connection' do
      it 'Symbol instance should response to eql' do
        :a.eql.should be_instance_of SymbolOperator

rhc_garb_spec.rb's contents:

    require 'spec'
    require 'right_http_connection-1.3.0/lib/right_http_connection'
    require 'garb-0.7.6/lib/garb'

    describe 'first require right_http_connection then require garb' do
      it 'Symbol instance should response to eql' do
        lambda{ :a.eql}.should raise_exception(NoMethodError)

garb_rhc_spec passed and printed "garb support has loaded", rhc_garb_spec passed and printed "garb support has not loaded"

If you sank into the same problem, you ought to check if there are files also require 'support' like garb.

I install a lower version right_http_connection and the problem vanlished.

    sudo gem uninstall right_http_connection -v '1.3.0'
    sudo gem install right_http_connection -v '1.2.4'

The gem right_http_connection-1.2.4 dose not require 'support':)

Discuss this post on stackOverflow