bblimke / webmock

Library for stubbing and setting expectations on HTTP requests in Ruby.
MIT License
3.98k stars 555 forks source link

uninitialized constant Net::WebMockNetHTTP::Get #122

Closed cassiomarques closed 13 years ago

cassiomarques commented 13 years ago

After upgrading to 1.7.0 to solve the problems with selenium/webdriver I started to get uninitialized constant Net::WebMockNetHTTP::Get every time I try to access something that is mocked. I'm also using VCR 1.10.3.

Is there anything that I need to change in order to make it work?

Thanks!

bblimke commented 13 years ago

WebMock 1.7.0 may not work with VCR 1.10.3, but @myronmarston is working on compatibility.

Could you please provide the stacktrace?

cassiomarques commented 13 years ago

The stacktrace shows no lines at all besides those of my own code. There are nothing related to webmock or vcr on the stack, just the error message itself about the missing constant.

I'll try to re-run it using the previous VCR version, do you think it can work or isn't it supposed to work with VCR at all at this point?

Thanks!

bblimke commented 13 years ago

Are you using it with rspec 2.6? You can add

RSpec.configure do |config|
    config.full_backtrace=true
end

in your spec_helper to get the full stacktrace.

cassiomarques commented 13 years ago

Hum... nope, 2.5.0, can't upgrade yet :(

bblimke commented 13 years ago

Here is how to enable full backtrace in old rspec versions http://spin.atomicobject.com/2010/12/28/rspec-backtrace-filtering/

cassiomarques commented 13 years ago

Thank you!

Here's the full stack trace:

 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing_from_s3_library'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:124:in `block in constantize'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:123:in `each'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:123:in `constantize'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/core_ext/string/inflections.rb:43:in `constantize'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/aws-2.4.5/lib/s3/s3_interface.rb:161:in `generate_rest_request'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/aws-2.4.5/lib/s3/s3_interface.rb:711:in `get_acl'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/aws-2.4.5/lib/s3/s3_interface.rb:773:in `get_bucket_acl'
 # ./app/models/amazon_account.rb:130:in `private_bucket_acl_as_xml'
 # ./lib/amazon/private_bucket_access_granter.rb:12:in `grant_access_to'
 # ./app/models/amazon_account.rb:146:in `allow_daily_digital_to_access_private_bucket'
 # ./spec/models/amazon_account_spec.rb:149:in `block (3 levels) in <top (required)>'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/vcr-1.10.3/lib/vcr/util/variable_args_block_caller.rb:8:in `call'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/vcr-1.10.3/lib/vcr/util/variable_args_block_caller.rb:8:in `call_block'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/vcr-1.10.3/lib/vcr.rb:76:in `use_cassette'
 # ./spec/models/amazon_account_spec.rb:145:in `block (3 levels) in <top (required)>'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.2/lib/rspec/monkey/spork/test_framework/rspec.rb:4:in `run_tests'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/spork-0.9.0.rc6/lib/spork/run_strategy/forking.rb:13:in `block in run'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/spork-0.9.0.rc6/lib/spork/forker.rb:21:in `block in initialize'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/spork-0.9.0.rc6/lib/spork/forker.rb:18:in `fork'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/spork-0.9.0.rc6/lib/spork/forker.rb:18:in `initialize'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/spork-0.9.0.rc6/lib/spork/run_strategy/forking.rb:9:in `new'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/spork-0.9.0.rc6/lib/spork/run_strategy/forking.rb:9:in `run'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/spork-0.9.0.rc6/lib/spork/server.rb:48:in `run'
bblimke commented 13 years ago

Thanks! That's definitely a problem with WebMock and I already know the reason. I'll try to fix it asap.

myronmarston commented 13 years ago

FWIW, config.full_backtrace=true has been around since at least RSpec 2.0. You can also pass --backtrace at the command line if you run your specs directly with the rspec command (as opposed to using rake or whatever).

And yes--VCR doesn't yet work with WebMock 1.7.0. I hope to have a release out later this week that fixes compatibility. Thanks for your patience :).

bblimke commented 13 years ago

Not sure if it's a problem with webmock or vcr-webmock compatibility but I'm not able to reproduce it. I tried different order of loading libraries 'aws' 'vcr' 'webmock' and everything works.

Are you able to write a simple code that can reproduce this issue? It's fine if it uses aws or aws-s3 gems, and doesn't need to be correct (passing) as long as it reproduces this error in 1.7.0.

myronmarston commented 13 years ago

It looks to me like the issue is here:

request                 = "Net::HTTP::#{method.capitalize}".constantize.new(path)

Because you have replaced Net::HTTP with your own constant (Net::WebMockNetHTTP), it is looking for Net::WebMockNetHTTP::Get. Two ideas to fix this:

bblimke commented 13 years ago

So it's how activesupport String#constantize works

require 'webmock' require 'active_support/inflector' "Net::HTTP::Get".constantize NameError: uninitialized constant Net::WebMockNetHTTP::Get

@myronmarston: I don't understand the second idea. How can I assign a class to a variable instead of a constant? Sample code?

myronmarston commented 13 years ago
require 'net/http'
my_net_http = Class.new(Net::HTTP) do
  # override Net::HTTP methods here
end
my_net_http.name # => nil (since it hasn't been assigned to a constant yet)
Net.send(:const_set, :HTTP, my_net_http)
my_net_http.name # => "Net::HTTP"
bblimke commented 13 years ago

I learnt something new today. Thanks Myron.

Anyway, this idea is not going to help, since even if my class is called Net::HTTP. In ruby 1.8 const_defined?("Get") will return false. This is not the issue with Ruby 1.9 where const_defined? by default checks for the constant in ancestors too.

myronmarston commented 13 years ago

Interesting--I didn't know const_defined? had different behavior in 1.8 and 1.9. Will it work to define const_missing and delegate that to the original Net::HTTP?

myronmarston commented 13 years ago

BTW, you might want to look at artifice to see how it does it--it uses the const replacement trick with Net::HTTP and seems to have solved this problem.

bblimke commented 13 years ago

It didn't ;)

ruby-1.8.7-p352 :002 > require 'active_support/inflector' ruby-1.8.7-p352 :004 > require 'net/http' => true ruby-1.8.7-p352 :005 > "Net::HTTP::Get".constantize => Net::HTTP::Get ruby-1.8.7-p352 :006 > require 'artifice' => true ruby-1.8.7-p352 :008 > Artifice.activate_with(nil) => nil ruby-1.8.7-p352 :009 > "Net::HTTP::Get".constantize NameError: uninitialized constant Artifice::Net::HTTP::Get

myronmarston commented 13 years ago

Nevermind then... Good luck figuring it out! I'll be curious to see what solution you come up with.

myronmarston commented 13 years ago

ooh...one more idea (I'm chock full of ideas but not necessarily solutions!): can you override const_defined? on your Net::HTTP subclass when running 1.8 so that it returns the right value?

bblimke commented 13 years ago

This one works

def const_defined?(name)
  super || self.superclass.const_defined?(name)
end

Can you think of any negative side effects?

myronmarston commented 13 years ago

Can you think of any negative side effects?

As a system wide monkey path to Object#const_defined?, yes--you are changing the behavior of a core method to ruby. Assuming you define this only on your Net::HTTP subclass--no negative side effects come to mind if it does indeed fix the issue. I'd probably only do this for 1.8 though, as it's unnecessary on 1.9, right?

bblimke commented 13 years ago

Fixed and released as 1.7.1

cassiomarques commented 13 years ago

I'll test it guys, thank you very much, you rock!

cassiomarques commented 13 years ago

I still have an error, but I will assume this is happening because VCR is not supposed to work with webmock >= 1.7, correct?

 uninitialized constant Net::WebMockNetHTTP::Get
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing_from_s3_library'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:124:in `block in constantize'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:123:in `each'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:123:in `constantize'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/core_ext/string/inflections.rb:43:in `constantize'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/aws-2.4.5/lib/s3/s3_interface.rb:161:in `generate_rest_request'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/aws-2.4.5/lib/s3/s3_interface.rb:711:in `get_acl'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/aws-2.4.5/lib/s3/s3_interface.rb:773:in `get_bucket_acl'
 # ./app/models/amazon_account.rb:130:in `private_bucket_acl_as_xml'
 # ./lib/amazon/private_bucket_access_granter.rb:12:in `grant_access_to'
 # ./app/models/amazon_account.rb:146:in `allow_daily_digital_to_access_private_bucket'
 # ./spec/models/amazon_account_spec.rb:149:in `block (3 levels) in <top (required)>'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/vcr-1.10.3/lib/vcr/util/variable_args_block_caller.rb:8:in `call'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/vcr-1.10.3/lib/vcr/util/variable_args_block_caller.rb:8:in `call_block'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/vcr-1.10.3/lib/vcr.rb:76:in `use_cassette'
 # ./spec/models/amazon_account_spec.rb:145:in `block (3 levels) in <top (required)>'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.2/lib/rspec/monkey/spork/test_framework/rspec.rb:4:in `run_tests'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/spork-0.9.0.rc6/lib/spork/run_strategy/forking.rb:13:in `block in run'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/spork-0.9.0.rc6/lib/spork/forker.rb:21:in `block in initialize'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/spork-0.9.0.rc6/lib/spork/forker.rb:18:in `fork'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/spork-0.9.0.rc6/lib/spork/forker.rb:18:in `initialize'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/spork-0.9.0.rc6/lib/spork/run_strategy/forking.rb:9:in `new'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/spork-0.9.0.rc6/lib/spork/run_strategy/forking.rb:9:in `run'
 # /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/spork-0.9.0.rc6/lib/spork/server.rb:48:in `run'
myronmarston commented 13 years ago

That looks like the same error--I don't think it's a VCR thing. @bblimke: you may want to add a spec that uses Net::HTTP in the same fashion as the aws gem. I think you'll need to still do what I suggested in my comment above to ensure your class is still named Net::HTTP rather than Net::WebMockNetHTTP.

bblimke commented 13 years ago

Weird. @cassiomarques: can you confirm you use WebMock 1.7.1 not 1.7.0? Although I released 1.7.1, Rubygems still seem to serve 1.7.0 for some reason.

cassiomarques commented 13 years ago

@bblimke yeah, I uninstalled webmock (all versions), re-bundled and bundle show webmock returns 1.7.1

bblimke commented 13 years ago

It's difficult to fix it without being able to reproduce that. Here is an example I used to reproduce it 1.7.0

ruby-1.8.7-p352 :001 > require 'webmock'
 => true 
ruby-1.8.7-p352 :002 > require 'active_support/inflector'
 => true 
ruby-1.8.7-p352 :003 > WebMock.version
 => "1.7.0" 
ruby-1.8.7-p352 :004 > "Net::HTTP::Get".constantize
NameError: uninitialized constant Net::WebMockNetHTTP::Get
ruby-1.8.7-p352 :005 > "Net::WebMockHTTP::Get".constantize
NameError: uninitialized constant Net::WebMockHTTP

but it works with 1.7.1

ruby-1.8.7-p352 :004 > require 'webmock'
=> true 
ruby-1.8.7-p352 :005 > require 'active_support/inflector'
  => true 
ruby-1.8.7-p352 :006 > WebMock.version
 => "1.7.1" 
ruby-1.8.7-p352 :007 > "Net::HTTP::Get".constantize
 => Net::HTTP::Get 
ruby-1.8.7-p352 :007 > "Net::WebMockHTTP::Get".constantize
=> Net::HTTP::Get
bblimke commented 13 years ago

Another test against active support 3.0.7 and aws 2.4.5 same as in your stacktrace

Version 1.7.0

ruby-1.8.7-p352 :001 > require 'active_support/inflector'
 => true 
ruby-1.8.7-p352 :002 > require 'aws'
 => true 
ruby-1.8.7-p352 :003 > require 'webmock'
 => true 
ruby-1.8.7-p352 :004 > WebMock.version
 => "1.7.0" 
ruby-1.8.7-p352 :006 > i = Aws::S3Interface.new("a","b")
New Aws::S3Interface using per_request-connection mode
 => #<Aws::S3Interface:0x101fe1648 ...
ruby-1.8.7-p352 :007 > i.generate_rest_request("get", {})
NameError: uninitialized constant Net::WebMockNetHTTP::Get

Version 1.7.1

ruby-1.8.7-p352 :001 > require 'active_support/inflector'
 => true 
ruby-1.8.7-p352 :002 > require 'aws'
 => true 
ruby-1.8.7-p352 :003 > require 'webmock'
 => true 
ruby-1.8.7-p352 :004 > WebMock.version
 => "1.7.1" 
ruby-1.8.7-p352 :006 > i = Aws::S3Interface.new("a","b")
 => #<Aws::S3Interface:0x101ff27b8
ruby-1.8.7-p352 :007 > i.generate_rest_request("get", {})
=> {:protocol=>"https", :request=>#<Net::HTTP::Get GET>, :server=>"s3.amazonaws.com", :port=>443} 

@cassiomarques. Could you print WebMock.version in your failing test? maybe it's some loading issue?

cassiomarques commented 13 years ago

I used exactly the same code that triggers the error in my app (retrieving the ACL for a given bucket). I loaded the same gems you loaded in your previous message (no VCR).

ruby-1.9.2-p180 :001 > require "active_support/inflector"
 => true 
ruby-1.9.2-p180 :002 > require "aws"
 => true 
ruby-1.9.2-p180 :003 > require "webmock"
 => true 
ruby-1.9.2-p180 :005 > WebMock.version
 => "1.7.1" 
ruby-1.9.2-p180 :006 > interface = Aws::S3Interface.new "foo", "bar"
New Aws::S3Interface using per_request-connection mode
 => #<Aws::S3Interface:0x00000101d5a370 @params={:server=>"s3.amazonaws.com", :port=>443, :service=>"/", :protocol=>"https", ...
ruby-1.9.2-p180 :007 > interface.get_bucket_acl("somebucket")

["/Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:124:in `block in constantize'", "/Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:123:in`each'", "/Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:123:in `constantize'", "/Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/core_ext/string/inflections.rb:43:in`constantize'", "/Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/aws-2.4.5/lib/s3/s3_interface.rb:161:in `generate_rest_request'", "/Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/aws-2.4.5/lib/s3/s3_interface.rb:711:in`get_acl'", "/Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/aws-2.4.5/lib/s3/s3_interface.rb:773:in `get_bucket_acl'", "(irb):7:in`irb_binding'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/workspace.rb:80:in `eval'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/workspace.rb:80:in`evaluate'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/context.rb:254:in `evaluate'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:159:in`block (2 levels) in eval_input'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:273:in `signal_status'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:156:in`block in eval_input'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:243:in `block (2 levels) in each_top_level_statement'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in`loop'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in each_top_level_statement'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in`catch'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `each_top_level_statement'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:155:in`eval_input'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:70:in `block in start'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:69:in`catch'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:69:in `start'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in`<main>'"].join('
')}
Request was:  -none-
Response was: -none-

["/Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:124:in `block in constantize'", "/Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:123:in`each'", "/Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:123:in `constantize'", "/Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/core_ext/string/inflections.rb:43:in`constantize'", "/Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/aws-2.4.5/lib/s3/s3_interface.rb:161:in `generate_rest_request'", "/Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/aws-2.4.5/lib/s3/s3_interface.rb:711:in`get_acl'", "/Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/aws-2.4.5/lib/s3/s3_interface.rb:773:in `get_bucket_acl'", "(irb):7:in`irb_binding'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/workspace.rb:80:in `eval'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/workspace.rb:80:in`evaluate'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/context.rb:254:in `evaluate'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:159:in`block (2 levels) in eval_input'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:273:in `signal_status'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:156:in`block in eval_input'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:243:in `block (2 levels) in each_top_level_statement'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in`loop'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in each_top_level_statement'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in`catch'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `each_top_level_statement'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:155:in`eval_input'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:70:in `block in start'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:69:in`catch'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb.rb:69:in `start'", "/Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in`<main>'"].join('
')}
Request was:  -none-
Response was: -none-
NameError: uninitialized constant Net::WebMockNetHTTP::Get
  from /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:124:in `block in constantize'
  from /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:123:in`each'
  from /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/inflector/methods.rb:123:in `constantize'
  from /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/core_ext/string/inflections.rb:43:in`constantize'
  from /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/aws-2.4.5/lib/s3/s3_interface.rb:161:in `generate_rest_request'
  from /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/aws-2.4.5/lib/s3/s3_interface.rb:711:in`get_acl'
  from /Users/cassiommc/.rvm/gems/ruby-1.9.2-p180/gems/aws-2.4.5/lib/s3/s3_interface.rb:773:in `get_bucket_acl'
  from (irb):7
  from /Users/cassiommc/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in`<main>'
ruby-1.9.2-p180 :008 > 
bblimke commented 13 years ago

The problem still exists on Ruby 1.9 and aws 2.4.5

AWS 2.4.5 monkeypatches constantize on String globally :( https://github.com/appoxy/aws/blob/v2.4.3/lib/awsbase/support.rb#L42-61

Fortunately AWS 2.5.0 doesn't depend on active support and thank's to @phiggins constantize is not needed https://github.com/appoxy/aws/commit/e5fca62caa4b4343d5212ee7f56d4691f484d8a1#lib/awsbase

On the other side WebMock indeed still changes const_get(name, false) behaviour in Ruby 1.9 so I'm going to make another patch ;)

cassiomarques commented 13 years ago

You rock! Thanks!

bblimke commented 13 years ago

Fixed (again) and released as 1.7.2

cassiomarques commented 13 years ago

Seems to be working fine now, thatk you very much!

I'm using it with VCR head and everything seems to be fine.