Create the plugin without test-unit and specify the path for the dummy application:
rails plugin new foobar --skip-test-unit --dummy-path=spec/dummy
Add rspec-rails as a development dependency to the gemspec file (foobar.gemspec):
Gem::Specification.new do |s|
.
.
.
s.add_development_dependency "rspec-rails"
end
Run bundle install
Create a symlink from the dummy app to the plugin spec directory and run the Rspec install generator:
cd spec/dummy
ln -s ../../spec
rails generate rspec:install
cd -
Now edit spec/spec_helper.rb (or spec/rails_helper.rb in rails 4+, not sure about older versions) changing this line (line 3):
require File.expand_path("../../config/environment", __FILE__)
To this:
require File.expand_path("../dummy/config/environment", __FILE__)
Now you can run Rspec from the root of your plugin and it will pick up specs from the dummy application as well.
bundle exec rspec spec
I wrote about this in more detail, showing how to also set up capybara, spork and guard in a rails plugin with a dummy application:
https://web.archive.org/web/20130125091106/http://namick.tumblr.com/post/17663752365/how-to-create-a-gemified-plugin-with-rails-3-2-rspec