ArgumentError mystery with jruby/rspec-1.1.11

I just got bitten by a strange issue with rspec-1.1.11 and jruby
1.1.3-1.1.6RC1. I’d love to know what the problem was if anyone has
any ideas. It’s almost as if, rspec didn’t like something about this
particular class since substituting others worked fine. It does work
with Rspec edge so I guess its not too important. Hopefully if anyone
else runs into this they’ll hit upon this.



require ‘./spring.jar’

describe “test with spring” do

it "should not raise ArgumentError" do

Java #
line 7


jruby-1.1.3/bin/jruby -v -S spec -v
jruby 1.1.3 (ruby 1.8.6 patchlevel 114) (2008-12-08 rev 6586) [x86_64-
rspec 1.1.11

jruby-1.1.3/bin/jruby -S spec -fs -b reproduce.rb

test with spring

  • should not raise ArgumentError (ERROR - 1)

ArgumentError in ‘test with spring should not raise ArgumentError’
main.rb:23:in describe' /home/jis/compsvc/lenny/tmp/x/./reproduce.rb:7: /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/ example_methods.rb:81:ininstance_eval’
example_methods.rb:81:in eval_block' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/ example_methods.rb:15:inexecute’
timeout' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/ example_methods.rb:12:inexecute’
example_group_methods.rb:245:in execute_examples' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/ example_group_methods.rb:244:ineach’
example_group_methods.rb:244:in execute_examples' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/ example_group_methods.rb:141:inrun’
example_group_runner.rb:22:in run' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/runner/ example_group_runner.rb:21:ineach’
example_group_runner.rb:21:in run' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/runner/ options.rb:115:inrun_examples’
command_line.rb:10:in run' /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/bin/spec:4: /Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/bin/spec:19:inload’

/jruby-1.1.3/bin/jruby -v rspec/bin/spec -v
jruby 1.1.3 (ruby 1.8.6 patchlevel 114) (2008-12-08 rev 6586) [x86_64-

jruby-1.1.3/bin/jruby rspec/bin/spec -fs reproduce.rb

test with spring

  • should not raise ArgumentError

Finished in 0.329 seconds

1 example, 0 failures

We’ve seen this behavior again, this time with rspec-1.1.12 and jruby
1.2.0RC1; the common factors seem to be:

(1) jruby
(2) rspec 1.1.11 or 1.1.12
(3) naming a java class with the string ‘context’ or ‘Context’ in its

In this case the bit of ruby causing trouble was:

   SecurityContextHolder =


And running ‘jruby script/spec -b …’ gave:

ArgumentError in ‘ManuscriptPublishedController check_unauthorized
should respond with unauthorized for create if user does not have
create_example_group' [...]/jruby-1.2.0RC1/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/dsl/main.rb:25:indescribe’

Replacing the above SecurityContextHolder definition with an import:

     import 'org.acegisecurity.context.SecurityContextHolder'

fixed the errors. Any explanations out there?

   Arthur S.

It seems this is actually related to the java package name containing
‘context’. I’ve posted a rspec bug for this along with a simple case
to demonstrate. I realize this may wind up kicked over to the JRuby


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs