« Return to Thread: Can module spec "behave like" controller spec?

Can module spec "behave like" controller spec?

by Shaker :: Rate this Message:

Reply to Author | View in Thread

Hello everyone:
    Right now I am writing spec on modules, which are provided by my colleagues. Some of the modules actually contain action methods. I tried very hard to spec those action methods in modules. But it seems that  the rspec does not allow module spec to 'get' action like controller does. After I saw the documentation, I then used :behaviour_type=>:controller. However, it failed again. It reported an error for me. For illustration, I'd like a simple example.
module MyModule
    def copy #an action method
        render :partial=>"/index", :layout=>false
    end
end

describe MyModule, :behaviour_type=>:controller do
    it "should render partial index" do
        get 'copy' #test code not provided yet, just want to get the action
    end
end
The error reported was: undefined method 'new' for MyModule:Module. Do you guys have any idea of the error? And how should I test the action methods in modules?
Cheers!

 « Return to Thread: Can module spec "behave like" controller spec?