How to test resource_controller hooks

Updated . Posted . Visible to the public.

When using the resource_controller gem Show archive.org snapshot you often hook onto events like this:
update.before do
do_something
end

For testing such things in your controller you should -- as always -- not trigger something that eventually calls the thing you want.\
Instead, in your specs, have resource_controller run those hooks like it does itself. Like that:

describe 'before update' do
  it 'should do something' do
    controller.should_receive :do_something
    controller.send :before, :update
  end
end
Arne Hartherz
Last edit
Keywords
rspec
License
Source code in this card is licensed under the MIT License.
Posted by Arne Hartherz to makandra dev (2011-06-07 15:49)