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

JRuby renders nodes without their namespace when subclassing Node #695

Closed
benlangfeld opened this Issue Jun 8, 2012 · 6 comments

Comments

Projects
None yet
3 participants
@benlangfeld
Contributor

benlangfeld commented Jun 8, 2012

Affected ruby versions

  • JRuby

Affected nokogiri versions

  • 1.5.3 (prior 1.5.x releases break on nil prefixes)

Test case

require 'nokogiri'

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

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

  subject { described_class.new 'foo', doc }

  context 'with a namespace set' do
    let(:ns_href) { 'foo' }

    before do
      ns = subject.add_namespace nil, ns_href
      subject.namespace = ns
    end

    describe '#to_xml' do
      it 'should have the correct namespace in the rendered XML' do
        subject.to_xml.should match(/xmlns="foo"/)
      end
    end
  end
end

describe Nokogiri::XML::Node do
  it_should_behave_like 'to_xml'
end

describe Foo do
  it_should_behave_like 'to_xml'
end

Result

{10:57}[jruby-1.6.7]~/Desktop/nokogiri ben% be rspec nokogiri_spec.rb
.F

Failures:

  1) Foo it should behave like to_xml with a namespace set#to_xml should have the correct namespace in the rendered XML
     Failure/Error: subject.to_xml.should match(/xmlns="foo"/)
       expected "<foo/>" to match /xmlns="foo"/
     Shared Example Group: "to_xml" called from ./nokogiri_spec.rb:31
     # ./nokogiri_spec.rb:20:in `(root)'

Finished in 0.266 seconds
2 examples, 1 failure

Failed examples:

rspec ./nokogiri_spec.rb:19 # Foo it should behave like to_xml with a namespace set#to_xml should have the correct namespace in the rendered XML
bundle exec rspec nokogiri_spec.rb  24.13s user 0.98s system 247% cpu 10.131 total
@flavorjones

This comment has been minimized.

Member

flavorjones commented Jun 8, 2012

Clearest. Bug report. Ever.

@benlangfeld

This comment has been minimized.

Contributor

benlangfeld commented Jun 8, 2012

I've had some practice with Nokogiri JRuby bugs ;)

@yokolet

This comment has been minimized.

Member

yokolet commented Jun 14, 2012

@flavorjones yes, it is.

@benlangfeld Sorry for making you to practice those. :)
The bug has been fixed in rev. 4d05f95 . I'm hoping the next release won't bother you in terms of namespace.

@yokolet yokolet closed this Jun 14, 2012

@benlangfeld

This comment has been minimized.

Contributor

benlangfeld commented Jun 14, 2012

@yokolet Thanks. Any chance we could get an RC including this change?

@flavorjones

This comment has been minimized.

Member

flavorjones commented Jun 14, 2012

Yup, will do today.
On Jun 14, 2012 4:48 AM, "Ben Langfeld" <
reply@reply.github.com>
wrote:

@yokolet Thanks. Any chance we could get an RC including this change?


Reply to this email directly or view it on GitHub:
https://github.com/tenderlove/nokogiri/issues/695#issuecomment-6323222

@flavorjones

This comment has been minimized.

Member

flavorjones commented Jun 14, 2012

1.5.5.rc2 is out

benlangfeld added a commit to adhearsion/nokogiri that referenced this issue Jul 4, 2012

yokolet added a commit that referenced this issue Jul 8, 2012

Merge pull request #723 from adhearsion/feature/prefixed_attribute_ac…
…cessors

Merges failing test case for issue #712 and #695.

Thanks!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment