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

Failures with Ruby 2.0.0 #193

Closed
bkabrda opened this issue Mar 15, 2013 · 4 comments
Closed

Failures with Ruby 2.0.0 #193

bkabrda opened this issue Mar 15, 2013 · 4 comments

Comments

@bkabrda
Copy link

bkabrda commented Mar 15, 2013

Hi,
I'm observing these failures with Ruby 2.0.0:

  1) HTTParty two child classes inheriting from one parent should dup the proc on the child class
     Failure/Error: @child1.default_options[:imaginary_option].should == imaginary_option
       expected: #<Proc:0x00000002d01338@/builddir/build/BUILD/rubygem-httparty-0.10.2/usr/share/gems/gems/httparty-0.10.2/spec/httparty_spec.rb:597 (lambda)>
            got: #<Proc:0x00000002d00f00@/builddir/build/BUILD/rubygem-httparty-0.10.2/usr/share/gems/gems/httparty-0.10.2/spec/httparty_spec.rb:597 (lambda)> (using ==)
     # /usr/local/share/gems/gems/rspec-expectations-2.8.0/lib/rspec/expectations/fail_with.rb:32:in `fail_with'
     # /usr/local/share/gems/gems/rspec-expectations-2.8.0/lib/rspec/matchers/operator_matcher.rb:47:in `fail_with_message'
     # /usr/local/share/gems/gems/rspec-expectations-2.8.0/lib/rspec/matchers/operator_matcher.rb:69:in `__delegate_operator'
     # /usr/local/share/gems/gems/rspec-expectations-2.8.0/lib/rspec/matchers/operator_matcher.rb:59:in `eval_match'
     # /usr/local/share/gems/gems/rspec-expectations-2.8.0/lib/rspec/matchers/operator_matcher.rb:28:in `block in use_custom_matcher_or_delegate'
     # /builddir/build/BUILD/rubygem-httparty-0.10.2/usr/share/gems/gems/httparty-0.10.2/spec/httparty_spec.rb:601:in `block (3 levels) in <top (required)>'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:80:in `instance_eval'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:80:in `block in run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:173:in `with_around_hooks'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:77:in `run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:355:in `block in run_examples'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:351:in `map'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:351:in `run_examples'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:337:in `run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `block in run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `map'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `map'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `block in run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/reporter.rb:34:in `report'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:25:in `run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun'

  2) HTTParty::Response semantic methods for response codes for specific codes responds to multiple_choice?
     Failure/Error: response.__send__(method).should be_true
     NoMethodError:
       undefined method `call' for "":String
     # /builddir/build/BUILD/rubygem-httparty-0.10.2/usr/share/gems/gems/httparty-0.10.2/lib/httparty/response.rb:18:in `parsed_response'
     # /builddir/build/BUILD/rubygem-httparty-0.10.2/usr/share/gems/gems/httparty-0.10.2/lib/httparty/response.rb:51:in `method_missing'
     # /builddir/build/BUILD/rubygem-httparty-0.10.2/usr/share/gems/gems/httparty-0.10.2/spec/httparty/response_spec.rb:202:in `block (5 levels) in <top (required)>'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:80:in `instance_eval'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:80:in `block in run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:173:in `with_around_hooks'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:77:in `run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:355:in `block in run_examples'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:351:in `map'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:351:in `run_examples'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:337:in `run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `block in run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `map'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `block in run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `map'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `map'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `block in run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/reporter.rb:34:in `report'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:25:in `run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
     # /usr/local/share/gems/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun'

Any idea what's going on in there?
Thanks.

@nixpulvis
Copy link
Contributor

in ruby 2.0 Proc objects cannot be compared with == or eql? anymore.

proc = Proc.new { x = 1 }
proc == proc.clone     #=> false
proc.eql? proc.clone   #=> false

To countinue testing this might need to look into something like RubyVM::InstructionSequence.of(block)
see http://stackoverflow.com/questions/14487601/how-is-proc-evaluated

@nixpulvis
Copy link
Contributor

As for the other bug it's a bit odd.

httparty is dynamicly creating methods to access responce codes by name, ::Net::HTTPResponse::CODE_TO_OBJ has a mapping of codes to classes, httparty is comaring it's response code to the key of that hash in a method defined by a the name of the value (class) converted to underscores without ::Net::HTTP

For example:

response = HTTParty::Response(...)

::Net::HTTPResponse::CODE_TO_OBJ['100']   #=> Net::HTTPContinue
response.continue?                        #=> Not an exception

Now for the interesting part.

ruby 1.9.3

irb(main):008:0> ::Net::HTTPResponse::CODE_TO_OBJ["300"]
=> Net::HTTPMultipleChoice

ruby 2.0.0

irb(main):002:0> ::Net::HTTPResponse::CODE_TO_OBJ["300"]
=> Net::HTTPMultipleChoices

They did do a little to help backwards compatibility.

ruby 2.0.0

irb(main):015:0> ::Net::HTTPMultipleChoices
=> Net::HTTPMultipleChoices
irb(main):016:0> ::Net::HTTPMultipleChoice
=> Net::HTTPMultipleChoices
irb(main):017:0> 

Too bad it's for the pluralized name 😦

@nixpulvis
Copy link
Contributor

This can be closed now thanks to 1fde99b

@nixpulvis
Copy link
Contributor

jruby compat.version=2.0

irb(main):002:0> ::Net::HTTPResponse::CODE_TO_OBJ["300"]
=> Net::HTTPMultipleChoice

Grrrrrr 😦

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