Plugins - rspec_plugin generator

StarAdd to favorites

Rails gives us a generator to create plugins with ./script/generate plugin. It creates all the stub files, including some tests for you. What if you want to use RSpec instead of Test::Unit though?

./script/generate rspec_plugin

Yep, it's super basic, it just does all the same stuff as the regular plugin generator does, except it creates RSpec stubs for you.

There is one added bonus though, and that's that you can set up an individual database for your plugin.

./script/generate rspec_plugin my_plugin --with-database

This will create a schema.rb file where you can create the schema for your plugin specs, a database.yml file to configure the database connection, and set up some helpful stuff in spec_helper.rb Nice for quickly getting a plugin going with tests isolated against its own database.

The database stuff is based on code from Chapter 8 of Rails Plugins: Extending Rails Beyond the Core by James Adam. If you're writing a plugin, check it out, you'll definitely learn a few tricks.

./script/plugin install svn://evang.eli.st/public/plugins/rspec_plugin

Pat Maddox

http://evang.eli.st/blog/2007/4/4/rspec_plugin-generator

svn://evang.eli.st/public/plugins/rspec_plugin

Rails' (MIT)

  • Currently 5.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Misc. Enhancements

Tags

Comments

Add a comment

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?