[rspec-users] controller spec not loading controller classes

Chris Ochs chris at ochsnet.com
Wed Mar 14 19:32:01 UTC 2012


This is jruby 1.6.7, rspec 2, rails 3.0.9.

I have a simple controller spec as follows:

describe MoneyController, :type => :controller do
  describe "GET payout" do
    it "Pays out currency to user" do
      money = double("Cloud::Money")
      get :payout
    end
  end
end

Running rake spec results in the following.   MoneyController is in 
app/controllers, but rspec isn't loading any of my controllers. 

NameError: uninitialized constant MoneyController
    const_missing at org/jruby/RubyModule.java:2642
    const_missing at 
/home/marvel/.rvm/gems/jruby-1.6.7/gems/rspec-core-2.8.0/lib/rspec/core/backward_compatibility.rb:24
           (root) at 
/home/marvel/server/rails/spec/controllers/money_controller_spec.rb:1
             load at org/jruby/RubyKernel.java:1058
  load_spec_files at 
/home/marvel/server/rails/spec/controllers/money_controller_spec.rb:698
          collect at org/jruby/RubyArray.java:2331
  load_spec_files at 
/home/marvel/.rvm/gems/jruby-1.6.7/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698
              run at 
/home/marvel/.rvm/gems/jruby-1.6.7/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:22
   run_in_process at 
/home/marvel/.rvm/gems/jruby-1.6.7/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80
              run at 
/home/marvel/.rvm/gems/jruby-1.6.7/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69
          autorun at 
/home/marvel/.rvm/gems/jruby-1.6.7/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10


Digging deeper, I see  that rake spec loads up rails, then quits and then 
just runs rspec manually? It does this for all types of rspec tests.  Wth? 
  Immediately before the above backtrace, this is what I see:

/home/marvel/.rvm/rubies/jruby-1.6.7/bin/jruby -S rspec ./spec/test_spec.rb 
./spec/controllers/money_controller_spec.rb ./spec/models/dataset_spec.rb

Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20120314/c88b6ae2/attachment-0001.html>


More information about the rspec-users mailing list