[rspec-users] RSpec, plugins and stubbing controller methods

David Chelimsky dchelimsky at gmail.com
Thu Jun 24 21:45:32 EDT 2010

On Jun 22, 2010, at 8:10 PM, antonyw wrote:

> Hello,
> I have some code that is going to be used in other applications, so I
> decided to bundle the code (mostly controllers and views) into a plugin to
> make sharing easier. I copied the RSpec tests for the controllers into the
> plugin as well.
> The plugin RSpec tests run, however when it gets to stubbing controller
> methods it does not work. For example:
>    controller.stub!(:get_json_settings).and_return(Hash["host",
> "localhost", "port", "1234"])
> results in an error 'undefined local variable or method controller'.
> I know this code was working fine before, since I could run the RSpec tests
> against the controller prior to it becoming a plugin. So, I wondered when it
> starts up what must RSpec be missing when running in the plugin? Doing a
> --trace on rake spec and rake spec:plugin show the same the things being
> invoked and executed.
> Just wondering if anyone might have come across this issue before, or have
> any suggestions?

What versions of RSpec and Rails?

More information about the rspec-users mailing list