How to spec a rails plugin?
Basically, the same way you spec a rails application.
The cool trick is you take advantage of the spec_helper.rb of by loading it in the spec_helper of your plugin.
# ../vendor/plugin/YOUR_PLUGIN/spec/spec_helper.rb begin # load your main app spec_helper require File.dirname(__FILE__) + '/../../../../spec/spec_helper' rescue LoadError puts "You need to install rspec in your base app" exit end
I took this idea from Pat Maddox’s rspec-plugin-generator. You can use that generator to generate the basic plugin boiler plate for you.
The caveats are, you need to have rspec installed on your main app and you need to actually have the plugin installed in a rails application to test it. In any case, this works for my current needs.
For more info see this post.