Substruct engine + rspec_on_rails not co-operating


I promised a friend of mine I'd help update his online store. To get something up fast, I thought I'd try Substruct. But I can't make rspec specs run with it installed.

I've got the 1.2 RC 1 gem installed, and my environment.rb starts "module Engines; EdgeRails = true; end"

I've succuessfully installed Engines and Substruct, got the database set up, and managed to rub Webrick and log in to the admin section. So the app seems fine.

I generated a controller with "script/generate rspec_controller stock_list_import", but I can't run it. rspec dies with the error below. This is the exact same error I had before I configured everything correctly (if I remember right, before I set the EdgeRails constant in Engines).

I don't understand why SubstructApplicationController is not available to the spec, because:
  - the spec requires spec/spec_helper
  - spec/spec_helper requires config/environment
  - config/environment requires config/boot AND calls Engines.start :substruct

surely this is near enough the same as booting Webrick?

Any ideas why it doesn't work? And before anyone asks, I'm an rspec whore. Using Test::Unit IS out of the question :slight_smile: (not that I've tried that anyway)


$ rake spec:controllers
(in /Users/ashleymoran/Documents/Development/Stalmine/stalmine_tech)
<snip database stuff>
/opt/local/bin/ruby -I"/opt/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/lib" "/opt/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/bin/spec" "spec/controllers/stock_list_import_controller_spec.rb"
/opt/local/lib/ruby/gems/1.8/gems/activesupport- `const_missing': uninitialized constant ApplicationController::SubstructApplicationController (NameError)
         from /Users/ashleymoran/Documents/Development/Stalmine/stalmine_tech/config/../app/controllers/application.rb:5
         from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
         from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require'
         from /opt/local/lib/ruby/gems/1.8/gems/activesupport- `require'
         from /opt/local/lib/ruby/gems/1.8/gems/activesupport- `new_constants_in'
         from /opt/local/lib/ruby/gems/1.8/gems/activesupport- `require'
         from /Users/ashleymoran/Documents/Development/Stalmine/stalmine_tech/config/../vendor/plugins/rspec/lib/rspec_on_rails.rb:1
         from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
          ... 20 levels...
         from /opt/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/lib/spec/runner/command_line.rb:21:in `run'
         from /opt/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/lib/spec/runner/command_line.rb:15:in `each'
         from /opt/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/lib/spec/runner/command_line.rb:15:in `run'
         from /opt/local/lib/ruby/gems/1.8/gems/rspec-0.7.4/bin/spec:4
rake aborted!
Command failed with status (1): [/opt/local/bin/ruby -I"/opt/local/lib/ruby...]

I’m at a loss here because I have no clue what rspec is…url?

RSpec is a behaviour driven development (BDD) framework -

It's like Test::Unit/TDD, but you get more benefit out of it faster, because it forces you to think about the problem in a more productive way. (IMHO, I'm an rspec fanboy)



I had a look last night, figured out that the Engines plugin modifies the $LOAD_PATH variable, decided that must be broken when running rspec, so I ran it again to get the exact error message ... and it worked :-S I don't think I even changed anything...

This reminds me of the story Tom Knight and the Lisp Machine ( I read almost ten years ago. I didn't think it ever actually happened!!!

Anyway as long as rspec is working I'm happy