I'm creating some gems that can be used within Rails controllers and views. I'd like to be able to test the gems independently. But I've not been able to figure out how to create an instance of Rails inside the gem to test that the gem will work inside a Rails app.
I strongly prefer to use RSpec, but could probably adapt a Test::Unit solution, or just use Test::Unit.
I'd also be interested in similar solutions for Rails plugins.
(I tried Googling, but "rails gem testing" shows me gems that are used for testing, not how to test a gem. I'm pretty sure I've seen an article or 2 on this topic.)
Take a look at others plugins (plugins and gems, same thing) test suites.
Testing plugins that enhances Active Record is pretty easy. You can use Active Record anywhere, so all you got to do in that case is to connect Active Record to a database (e.g. a in-memory sqlite database) and test your codez.
It gets harder when you want to test controller actions and such. My live validations plugin has a pretty extensive test suite that mocks out lots of things and lets me pass ERb views as a string, you could take a look at that.
Adapting these Test::Unit examples to RSpec should be trivial, as they do not piggyback on anything in Test::Unit.