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

Yet more JRuby issues when subclassing #702

Closed
benlangfeld opened this issue Jun 15, 2012 · 7 comments
Closed

Yet more JRuby issues when subclassing #702

benlangfeld opened this issue Jun 15, 2012 · 7 comments

Comments

@benlangfeld
Copy link
Contributor

Affected ruby versions

  • JRuby

Affected nokogiri versions

  • 1.5.x (including 1.5.5.rc2)

Test case

require 'nokogiri'

Foo = Class.new Nokogiri::XML::Node

shared_examples_for '#xpath' do
  let(:doc) { Nokogiri::XML::Document.new }

  subject { described_class.new 'foo', doc }

  context 'looking for an element inside a namespaced element' do
    let(:child_node) { described_class.new 'bar', doc }

    let(:outer_ns_href) { 'outer_ns' }

    before do
      ns = subject.add_namespace nil, outer_ns_href
      subject.namespace = ns
      subject << child_node
    end

    it 'should find the element' do
      x = subject.xpath("ns:bar", 'ns' => outer_ns_href)
      x.first.should be == child_node
    end
  end
end

describe Nokogiri::XML::Node do
  it_should_behave_like '#xpath'
end

describe Foo do
  it_should_behave_like '#xpath'
end

Result

{14:15}[jruby-1.6.7]~/Desktop/nokogiri ben% be rspec
.F

Failures:

  1) Foo it should behave like #xpath looking for an element inside a namespaced element should find the element
     Failure/Error: x.first.should be == child_node
       expected: == #<Foo:0xcd4 name="bar">
            got:    nil
     Shared Example Group: "#xpath" called from ./spec/nokogiri_spec.rb:33
     # ./spec/nokogiri_spec.rb:23:in `(root)'

Finished in 0.301 seconds
2 examples, 1 failure

Failed examples:

rspec ./spec/nokogiri_spec.rb:21 # Foo it should behave like #xpath looking for an element inside a namespaced element should find the element
bundle exec rspec  26.17s user 1.04s system 246% cpu 11.049 total
@benlangfeld
Copy link
Contributor Author

@yokolet: Can all of the code that needs moving to make everything work properly with subclasses just be moved in one go? It seems somewhat pointless to just trickle these fixes out one at a time.

@benlangfeld
Copy link
Contributor Author

It would be nice to run the entire nokogiri test suite against both an instance of XML::Node and an instance of a subclass thereof.

@emcgee
Copy link

emcgee commented Jun 22, 2012

@yokolet I'd be willing to offer a bounty to get this fix nudged up the queue a bit. Message me whatever you feel is reasonable - happy to help!

@yokolet
Copy link
Member

yokolet commented Jun 22, 2012

@benlangfeld Sorry for my lateness to get you back. I fixed the issue in rev. 053c26f . Now, XML::Node has all methods implemented and its subclass works like Element. I think this commit is the last.

@emcgee Thanks for the offer. But this bug fix doesn't deserve to a bounty since it is small and doesn't take much time. If you are willing to donate to Nokogiri project, I guess https://pledgie.com/campaigns/8187 is still working.

@benlangfeld
Copy link
Contributor Author

@yokolet That's great. Can we get an RC please?

@benlangfeld
Copy link
Contributor Author

Thanks a lot. Nokogiri 1.5.5 fixes ~100 spec failures on Blather. Now for EventMachine....

@yokolet
Copy link
Member

yokolet commented Jun 25, 2012

Aw, 100 spec failures... That's so sorry to have bothered you so much. I'm glad to hear the failures had gone away.

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