tenderlove/nokogiri — Issue #560: Inheriting from Nokogiri::XML::Node on JRuby (1.6.4/5) fails
Author: benlangfeld
Created: 2011-11-02 16:20:07+00:00
State: open

The following simple test case:
```ruby

require 'nokogiri'

class MyNode < Nokogiri::XML::Node
def self.new(*args)
super
end
end

class MyNode2 < Nokogiri::XML::Node
def initialize(*args)
super
end
end

class MyNode3 < Nokogiri::XML::Node
end

describe MyNode do
subject { MyNode.new 'foo', Nokogiri::XML::Document.new }

its(:name) { should == 'foo' }

it 'should read/write attributes correctly' do
subject['foo'] = 'bar'
subject.attributes['foo'].should be_a Nokogiri::XML::Attr
end
end

describe MyNode2 do
subject { MyNode2.new 'foo', Nokogiri::XML::Document.new }

its(:name) { should == 'foo' }

it 'should read/write attributes correctly' do
subject['foo'] = 'bar'
subject.attributes['foo'].should be_a Nokogiri::XML::Attr
end
end

describe MyNode3 do
subject { MyNode3.new 'foo', Nokogiri::XML::Document.new }

its(:name) { should == 'foo' }

it 'should read/write attributes correctly' do
subject['foo'] = 'bar'
subject.attributes['foo'].should be_a Nokogiri::XML::Attr
end
end

describe Nokogiri::XML::Node do
subject { Nokogiri::XML::Node.new 'foo', Nokogiri::XML::Document.new }

its(:name) { should == 'foo' }

it 'should read/write attributes correctly' do
subject['foo'] = 'bar'
subject.attributes['foo'].should be_a Nokogiri::XML::Attr
end
end
```

causes the following failures:

```
{16:13}[jruby-1.6.5]~/Desktop ben% be rspec nokogiri_java.rb
F.F.F...

Failures:

1) MyNode should read/write attributes correctly
Failure/Error: subject.attributes['foo'].should be_a Nokogiri::XML::Attr
expected nil to be a kind of Nokogiri::XML::Attr
# ./nokogiri_java.rb:25:in `(root)'

2) MyNode2 should read/write attributes correctly
Failure/Error: subject.attributes['foo'].should be_a Nokogiri::XML::Attr
expected nil to be a kind of Nokogiri::XML::Attr
# ./nokogiri_java.rb:36:in `(root)'

3) MyNode3 should read/write attributes correctly
Failure/Error: subject.attributes['foo'].should be_a Nokogiri::XML::Attr
expected nil to be a kind of Nokogiri::XML::Attr
# ./nokogiri_java.rb:47:in `(root)'

Finished in 2.15 seconds
8 examples, 3 failures

Failed examples:

rspec ./nokogiri_java.rb:23 # MyNode should read/write attributes correctly
rspec ./nokogiri_java.rb:34 # MyNode2 should read/write attributes correctly
rspec ./nokogiri_java.rb:45 # MyNode3 should read/write attributes correctly
bundle exec rspec nokogiri_java.rb 31.41s user 1.75s system 233% cpu 14.218 total
```

These failures do not occur on CRuby (1.9.2/3) or when using Nokogiri 1.4.7. They have been introduced in Nokogiri 1.5, and unfortunately getting Nokogiri's tests running on JRuby is impossible, as is a bisect, due to the non-linear history between the 1.4 and 1.5 branches.