Well, I was having problems with my tests where:
 get :my_method, :other_params

Just wasn't seeming to trigger my method. When I ran "rake spec:controllers" it turns out that Radiant's site_controller_spec.rb would fail all over the place too -- errors tied to checking the response (success expected but was fail, etc).This would happen even if I didn't declare any methods -- just mixed in the code. Remove the include line from the extension_name.rb file and all was well.

Since I'm writing this extension BDD style, I didn't even bother to fire up a server (I don't have any views yet anyway) so I don't know if this would have run fine and that the errors might just be a testing setup thing.. As I mentioned originally, perhaps this is a case of the rSpec mixins fighting with mine.

My other thought was that possibly something special was needed to properly declare the controller and response objects -- that rSpec wasn't doing it's magic just right given my spec name or something. (in fact, I wound up moving my spec to /specs/controllers/site_controller_mods.rb to get some of the tests to pass).

Anyway, since then, I altered my approach to allow me to create my own controller that inherits from SiteController so my problems have gone away on their own. I would love to know what was up here, though.

-Chris

Rob Kuhr wrote:
I just added a module to the SiteController the other day for the
first time (thanks Cribbs).  I overwrite one of the methods actually.
Here is a sample of my module:

module TunaSiteOverride
  def self.included(base)
    base.class_eval do
      alias_method_chain :show_page, :tuna_site_override
    end
  end

  def show_page_with_ tuna_site_override
    # Code in here
  end
end

And here is my extension:

class TunaExtension < Radiant::Extension
  def activate
    SiteController.send :include, TunaSiteOverride
  end
end

What are the exact errors you are getting?  I am curious as to where
it is failing in the SiteController.  As for what is new in 0.6.6, no
clue.  I am JUST starting to hack into it :)

On Sat, May 10, 2008 at 12:50 PM, Chris Parrish
<[EMAIL PROTECTED]> wrote:
Ok, I've got a weird one here.  In an extension, I'm attempting to add a
method or two to SiteController.  I do this in the extension activate method
like:

 def activate
  SiteController.send :include, SiteControllerMods
 end

Then, in /lib/site_controller_mods.rb I define a module to add methods,
like:

 module SiteControllerMods
 end

Even without adding any methods, Radiant doesn't like this -- the built-in
SiteController specs start to fail left and right.  I've used this approach
in the past and it worked just fine -- what changed with 0.6.6?

Could this be something to do with Rails 2.0? Or maybe a conflict with
rSpec?

Is there a better approach?

-Chris
_______________________________________________
Radiant mailing list
Post:   [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant





_______________________________________________
Radiant mailing list
Post:   [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to