Skip to content

Instantly share code, notes, and snippets.

@luizpicolo
Forked from blackjk3/gemproject.md
Created December 6, 2016 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luizpicolo/73516e04da3b863436093a82a017a829 to your computer and use it in GitHub Desktop.
Save luizpicolo/73516e04da3b863436093a82a017a829 to your computer and use it in GitHub Desktop.
Creating a gem project with rspec

** Create the plugin without test-unit and specify the path for the dummy application:

rails plugin new $project_name --skip-test-unit --dummy-path=spec/dummy --mountable

** 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 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment