On Mar 11, 2010, at 1:26 AM, Nicolás Sanguinetti wrote: > We have an app that has "extensions" that are built as rails engines. > Each engine needs some code in the controllers, which we solved as > "include this module, call a method". In order to test it, though, we > don't want to "copy" the test for how that works into each engine, so > the idea is to write the tests once, in 'spec/lib/extensions_spec.rb', > where we are testing the other stuff that's common for all the > extensions (which are defined on lib/extensions.rb, thus the spec's > location) > > In order to do it, I'm declaring a 'sample' controller in the specs > (just include the module, call the method), and then writing a couple > specs for what we are doing. Problem is, I can't get rspec to > understand that that example group is a controller example groups. > > I have > > class MyExampleController < ApplicationController > include Extensions::ControllerHelpers > call_awesome_method # this, among other things, defines an > instance method on the controller that I want to test > end > > inside my spec, and after that I tried: > > 1) describe("controller helpers", :type => :controller) { > controller_name "my_example"; ... } > > It complains about controller_name not being a method of this dynamic > subclass of ActiveSupport::TestCase.
That seems like a really strange error. What is the actual stack trace? What versions of the test-unit gem do you have installed? What version of rails? rspec? If you uninstall the test-unit gem, will it work with the :type => :controller hash given to describe? (I've noticed *very* strange things with the test-unit gem installed in the past - such as a test suite which was 100% green, using a hybrid of mocha + rspec mocks/stubs. When the gem was uninstalled, half the test suite failed!) > After some time reading the source I figured that :type => :controller > pretty much just works for config.include/config.extend. So on to the > next thing: Have you taken a look at Spec::Example::ExampleGroupFactory? Not sure if this will help, but here's a patch that brynary and I banged out way back in rspec 1.1.9 to support spec/unit & spec/integration: (the usual disclaimer applies - all the good parts are his, all the bad parts are mine) http://gist.github.com/328919 That piece of the code might at least take you to a place where you can debug what's going on. Best, Scott _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users