Forum: RSpec ArgumentError mystery with jruby/rspec-1.1.11

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Lenny M. (Guest)
on 2008-12-09 00:05
(Received via mailing list)
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.

-lenny

# reproduce.rb

require './spring.jar'

describe "test with spring" do

    it "should not raise ArgumentError" do

Java
::org.springframework.context.support.ClassPathXmlApplicationContext #
line 7
    end

end

 > 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-
java]
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)

1)
ArgumentError in 'test with spring should not raise ArgumentError'
ArgumentError
/Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/extensions/
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:in `instance_eval'
/Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/
example_methods.rb:81:in `eval_block'
/Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/
example_methods.rb:15:in `execute'
/Users/Shared/eds_test/share/jruby-1.1.3/lib/ruby/1.8/timeout.rb:48:in
`timeout'
/Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/
example_methods.rb:12:in `execute'
/Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/
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:in `each'
/Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/example/
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:in `run'
/Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/runner/
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:in `each'
/Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/runner/
example_group_runner.rb:21:in `run'
/Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/runner/
options.rb:115:in `run_examples'
/Users/Shared/RubyGems/1.8/gems/rspec-1.1.11/lib/spec/runner/
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:in `load'
/Users/Shared/eds_test/share/jruby-1.1.3/bin/spec:19:


/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-
java]
rspec 1.1.11.1

 > 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
Arthur S. (Guest)
on 2009-03-04 22:46
(Received via mailing list)
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
name.

In this case the bit of ruby causing trouble was:

       SecurityContextHolder =
Java::org.acegisecurity.context.SecurityContextHolder

And running 'jruby script/spec -b ...' gave:

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

Replacing the above SecurityContextHolder definition with an import:

         import 'org.acegisecurity.context.SecurityContextHolder'

fixed the errors. Any explanations out there?

       Arthur S.
Lenny M. (Guest)
on 2009-03-10 17:32
(Received via mailing list)
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
people...

http://rspec.lighthouseapp.com/projects/5645-rspec...

-lenny
This topic is locked and can not be replied to.