R – Installing hpricot for JRuby

cucumberhpricotjrubyruby-on-railswebrat

I'm trying to look at cucumber for Jruby on Rails. One of the pre-requesites is webrat which has as pre-requisite hpricot.

I've installed the gem with hpricot using:

gem install hpricot –source http://code.whytheluckystiff.net –version 0.6.1 –platform java

This installs the java version of hpricot. I add the hpricot_scan.jar to the CLASSPATH but when I run:

cucumber features -n

I get the following output:

HpricotScanService.java:931:in `hpricot_scan': java.lang.NoSuchMethodError:
org.jruby.runtime.builtin.IRubyObject.getInstanceVariable(Ljava/lang/String;)Lorg/jruby/runtime/builtin/IRubyObject;
from HpricotScanService.java:1324:in `__hpricot_scan'
from null:-1:in `call'
from InvocationCallback.java:67:in `execute'
from FullFunctionCallbackMethod.java:69:in `call'
from DynamicMethod.java:243:in `call'
from CachingCallSite.java:283:in `cacheAndCall'
from CachingCallSite.java:121:in `callBlock'

etc.

If I compile the HpricotScanService.java file and add the resulting .class file to the classpath, I get:

Then I should see "Run"
private method `scan' called for Hpricot:Module (NoMethodError)
features/step_definitions/webrat_steps.rb:94:in `/^I should see "([^\"]*)"$/'
features/manage_activity.feature:9:in `Then I should see "Run"'

If I try to install later versions of the hpricot, then I get:

ERROR: Failed to build gem native extension.
C:/Program Files/Ruby/jruby-1.2.0/bin/../bin/jruby.bat extconf.rb install hpricot --platform java
C:/Program Files/Ruby/jruby-1.2.0/bin/../lib/ruby/1.8/mkmf.rb:7: JRuby does not support native extensions. Check wiki.jruby.org for alternatives. (Not
ImplementedError)
from C:/Program Files/Ruby/jruby-1.2.0/bin/../lib/ruby/1.8/mkmf.rb:1:in `require'
from extconf.rb:1

Does anyone have any clues as to what I'm doing wrong/not doing/where I'm being stupid.?

Using Windows XP, JRuby 1.2.0

Best Answer

FYI, version 1.4 of JRuby now supports version 0.7 of HPricot.

http://jruby.org/2009/11/02/jruby-1-4-0.html