Read more

How to test resource_controller hooks

Arne Hartherz
June 07, 2011Software engineer at makandra GmbH

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

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

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
Posted by Arne Hartherz to makandra dev (2011-06-07 17:49)