[rspec-users] rSpec'ing Plugins

Luis Lavena luislavena at gmail.com
Tue Jun 12 21:23:44 EDT 2007

On 6/12/07, s.ross <cwdinfo at gmail.com> wrote:
> I'm refactoring some of my code into a plugin and while it passes the
> base specs (as though it were part of the Rails app), I'd prefer that
> the plugin's specs live in the vendor/plugins/myplugin directory.
> Here's where I'm getting stuck. The plugin is MVC so instead of
> touching one part of Rails, it relies on several (model, view,
> controller) to work. That means to spec it requires rspec_on_rails.
> So, my questions are:
> 1. Is anyone doing this?

Yes, at least the M with plugins playing with Models.

I just created a spec folder, a spec_helper.rb inside of it and some
Fixtured Models, Database schema.

I used that approach to pluginize some code of one application.

Specs inside the plugin will be independent of models located in your
application, so:

app/models/user.rb will not clash with #{my_plugin}/spec/fixtures/models/user.rb

in that way, I isolate the plugin functionality and his behavior.

This is the pastie for my spec_helper inside plugin/spec folder:


> 2. Was it worth the effort or is Test::Unit easier for this kind of
> thing?
> I'd be happy if I could even get a model spec to pass, but I keep
> getting version mismatches between spec and rspec_on_rails even
> though I've done fresh gem install and plugin installs.

I don't know about that, I'm stuck at 0.9.4 gem + plugins until
migrate some of these applications.

> Any thoughts appreciated. I'd far prefer to use only rSpec on this
> project.

Luis Lavena
Multimedia systems
Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi

More information about the rspec-users mailing list