2
votes

I get the following error when trying to run a spec command on a model test.

The command is:

C:\Rspec Test\spec\models>spec bank_account_spec.rb

The error is :

c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rspec-rails-1.3.0/lib/spec/rails/matchers/ ar_be_valid.rb:2: uninitialized constant Spec::Rails (NameError) from c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rspec-rails-1.3.0/lib/spec/ra ils/matchers/ar_be_valid.rb:31:in require' from c:/jruby-1.5.0/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31 :inrequire' from C:/Rspec Test/vendor/rails/activesupport/lib/active_support/depende ncies.rb:158:in require' from c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rspec-rails-1.3.0/lib/spec/ra ils/matchers.rb:2 from c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rspec-rails-1.3.0/lib/spec/ra ils/matchers.rb:31:inrequire' from c:/jruby-1.5.0/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31 :in require' from C:/Rspec Test/vendor/rails/activesupport/lib/active_support/depende ncies.rb:158:inrequire' from c:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rspec-rails-1.3.0/lib/spec/ra ils.rb:15 ... 13 levels... from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rspec-1.3.0/bin/spec:5 from C:/jruby-1.5.0/lib/ruby/gems/1.8/gems/rspec-1.3.0/bin/spec:22:in `l oad' from c:/jruby-1.5.0/bin/spec:22

I actually tried changing version to 1.3.0 in the C:\jruby-1.5.0\bin\spec file but it results in the same error.

2

2 Answers

0
votes

This error suggests that the rspec framework is not getting loaded in the environment where this code is executing.

uninitialized constant Spec::Rails (NameError)

Rails 3 requires rspec 2 . Development of rspec-rails-2 has moved to github.com/rspec/rspec-rails.

0
votes

Not sure if this helps any more, since the question is quite old, but I just found it through google, so this might help someone.

I too had declared my matcher using Spec::Matchers.define, out of some example found online. Apparently, this is outdated, once I changed the definition to RSpec::Matchers.define (mind the 'R' in 'RSpec'), things worked fine again.

I only got the error in debug mode and I am not using JRuby, but this might still be worth a try, and it's more correct anyway.