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

JRuby doesn't coerce namespaces out of strings #715

Closed
benlangfeld opened this issue Jun 25, 2012 · 20 comments
Closed

JRuby doesn't coerce namespaces out of strings #715

benlangfeld opened this issue Jun 25, 2012 · 20 comments

Comments

@benlangfeld
Copy link
Contributor

Affected ruby versions

  • JRuby

Affected nokogiri versions

  • 1.5.x (including 1.5.5)

Test case

require 'nokogiri'

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

shared_examples_for "#<<" do
  let(:doc) { Nokogiri::XML::Document.new }

  subject { described_class.new 'foo', doc }

  it "should maintain element namespaces" do
    subject << '<foobar xmlns="barfoo"/>'
    child = subject.children.first
    child.name.should be == 'foobar'
    child.namespace.href.should be == 'barfoo'
  end
end

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

describe Foo do
  it_should_behave_like '#<<'
end

Result

{18:51}[ruby-1.9.3]~/Desktop/nokogiri ben% be rspec spec/nokogiri_spec.rb
..

Finished in 0.0051 seconds
2 examples, 0 failures

{18:50}[jruby-1.6.7.2]~/Desktop/nokogiri ben% be rspec spec/nokogiri_spec.rb
FF

Failures:

  1) Nokogiri::XML::Node it should behave like #<< should maintain element namespaces
     Failure/Error: child.namespace.href.should be == 'barfoo'
     NoMethodError:
       undefined method `href' for nil:NilClass
     Shared Example Group: "#<<" called from ./spec/nokogiri_spec.rb:19
     # ./spec/nokogiri_spec.rb:14:in `(root)'

  2) Foo it should behave like #<< should maintain element namespaces
     Failure/Error: child.namespace.href.should be == 'barfoo'
     NoMethodError:
       undefined method `href' for nil:NilClass
     Shared Example Group: "#<<" called from ./spec/nokogiri_spec.rb:23
     # ./spec/nokogiri_spec.rb:14:in `(root)'

Finished in 0.384 seconds
2 examples, 2 failures

Failed examples:

rspec ./spec/nokogiri_spec.rb:10 # Nokogiri::XML::Node it should behave like #<< should maintain element namespaces
rspec ./spec/nokogiri_spec.rb:10 # Foo it should behave like #<< should maintain element namespaces
bundle exec rspec spec/nokogiri_spec.rb  28.95s user 1.18s system 222% cpu 13.543 total
@benlangfeld
Copy link
Contributor Author

@yokolet @flavorjones Any word on this? Bounty up for grabs.

Tagging @bklang @emcgee

@flavorjones
Copy link
Member

Work is busy this week week for me and @jvshahid. Someone will get to it when we have some time.

@yokolet
Copy link
Member

yokolet commented Jun 28, 2012

Hello,

I pushed the fix just now. The rev. is 2d0cdea . As far as I tested, the two tests above passed.

@benlangfeld
Copy link
Contributor Author

Can we get an RC?

@flavorjones
Copy link
Member

Yes. Sometime this morning.
On Jun 28, 2012 5:46 AM, "Ben Langfeld" <
reply@reply.github.com>
wrote:

Can we get an RC?


Reply to this email directly or view it on GitHub:
#715 (comment)

@flavorjones
Copy link
Member

Blocked on releasing today for uninteresting reasons. Will get something out ASAP. Thanks for your patience.

@benlangfeld
Copy link
Contributor Author

Might that RC make its way out today?

@flavorjones
Copy link
Member

Sorry. More detail on the uninteresting reasons: I'm actually having difficulty building the windows gems all of a sudden. Something on my system changed, and I need to invest some time to figure out what. Apologies, and thanks for your patience. Hopefully today!

@benlangfeld
Copy link
Contributor Author

This is precisely why gemspecs are normally included in repos. And yes, I know all about the nokogiri policy.

I guess I'll just fork.

@tenderlove
Copy link
Member

The gemspecs know how to build windows binaries? Did that get included in bundler?

@benlangfeld
Copy link
Contributor Author

Not that I know of, but I don't personally care a jot about windows ;)

@flavorjones
Copy link
Member

Well that makes it OK then! <3 <3 <3
On Jul 3, 2012 2:59 PM, "Ben Langfeld" <
reply@reply.github.com>
wrote:

Not that I know of, but I don't personally care a jot about windows ;)


Reply to this email directly or view it on GitHub:
#715 (comment)

@benlangfeld
Copy link
Contributor Author

That's my point. Actual releases imply some kind of contract, a la semver, with regards to the code actually functioning. A git checkout does not. People understand this when they tag to a git repo in their Gemfile.

That said, I fully understand that the nokogiri team's opinion on this matter will never change, but it's also not fun to sit silently and watch it cause problems. Talk.to(self)

@benlangfeld
Copy link
Contributor Author

Unfortunately this is still broken.

require 'nokogiri'

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

shared_examples_for "#<<" do
  let(:doc) { Nokogiri::XML::Document.new }

  subject { described_class.new 'foo', doc }

  it "should maintain element namespaces" do
    subject << '<foobar xmlns="barfoo"/>'
    child = subject.children.first
    child.name.should be == 'foobar'
    child.namespace.href.should be == 'barfoo'
    child.attributes.should be_empty
  end

  it "should maintain element namespaces in URN form" do
    subject << '<foobar xmlns="urn:xmpp:foospec:barfoo"/>'
    child = subject.children.first
    child.name.should be == 'foobar'
    child.namespace.href.should be == 'urn:xmpp:foospec:barfoo'
    child.attributes.should be_empty
  end
end

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

describe Foo do
  it_should_behave_like '#<<'
end
{11:45}[jruby-1.6.7.2]~/Desktop/nokogiri ben% be rspec spec
.F.F

Failures:

  1) Nokogiri::XML::Node it should behave like #<< should maintain element namespaces in URN form
     Failure/Error: child.namespace.href.should be == 'urn:xmpp:foospec:barfoo'
     NoMethodError:
       undefined method `href' for nil:NilClass
     Shared Example Group: "#<<" called from ./spec/nokogiri_spec.rb:28
     # ./spec/nokogiri_spec.rb:22:in `(root)'

  2) Foo it should behave like #<< should maintain element namespaces in URN form
     Failure/Error: child.namespace.href.should be == 'urn:xmpp:foospec:barfoo'
     NoMethodError:
       undefined method `href' for nil:NilClass
     Shared Example Group: "#<<" called from ./spec/nokogiri_spec.rb:32
     # ./spec/nokogiri_spec.rb:22:in `(root)'

Finished in 0.406 seconds
4 examples, 2 failures

Failed examples:

rspec ./spec/nokogiri_spec.rb:18 # Nokogiri::XML::Node it should behave like #<< should maintain element namespaces in URN form
rspec ./spec/nokogiri_spec.rb:18 # Foo it should behave like #<< should maintain element namespaces in URN form
bundle exec rspec spec  26.54s user 1.04s system 251% cpu 10.965 total

{11:48}[ruby-1.9.3]~/Desktop/nokogiri ben% be rspec spec
zsh: correct 'rspec' to 'spec' [nyae]? n
....

Finished in 0.00751 seconds
4 examples, 0 failures

I notice that in fixes for these reports, there is no test coverage being added to avoid future regressions. Why is this?

@jvshahid
Copy link
Member

jvshahid commented Jul 4, 2012

thanks for following up and making sure that the bug is fixed. i added the failing tests to the test suite and will work on a fix shortly.

@benlangfeld
Copy link
Contributor Author

Thanks all :)

@benlangfeld
Copy link
Contributor Author

@flavorjones Given that nobody has expressed an interest in the 1.5.6.rc1 release on windows, and that a release for *nix is important to several people, can we please assume that those on windows can make do with 1.5.5 and just get the release out? Frankly, those windows users can wait for rc2.

@flavorjones
Copy link
Member

Yup.

@flavorjones
Copy link
Member

1.5.6.rc1 has been pushed.

@flavorjones
Copy link
Member

1.5.6.rc1 has been pushed only for JRuby and non-windows MRI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants