Skip to content

Instantly share code, notes, and snippets.

@mikebannister
Created September 14, 2011 15:34
Show Gist options
  • Save mikebannister/1216893 to your computer and use it in GitHub Desktop.
Save mikebannister/1216893 to your computer and use it in GitHub Desktop.
Rails engine w/ Rspec

NOTE!!!!!!!!! Ended up in trouble going down this path. Followed Rails 3 in Action method instead

generate

rails plugin new importable --dummy-path=spec/dummy --full --mountable && cd importable

in .gitignore change references to test/dummy to spec/dummy (rails bug¿)

spec/dummy/db/*.sqlite3
spec/dummy/log/*.log
spec/dummy/tmp/

check in

git init && git add . && git commit -am"generated engine"

add to gemspec

s.add_development_dependency 'rspec-rails'
s.add_development_dependency 'capybara'
s.add_development_dependency 'launchy'
s.add_development_dependency 'spork'
s.add_development_dependency 'turn'

bundle dependencies

bundle install

generate spec_helper

rails g rspec:install

change path in spec_helper to point to dummy

require File.expand_path("../dummy/config/environment", __FILE__)

add to dummy's Rakefile

load 'rspec/rails/tasks/rspec.rake'

in the engine's Rakefile change the default task

task :default => 'app:spec'

prep database

rake app:db:migrate && rake app:db:test:prepare

check in

git add . && git commit -am"test with rspec"

if you want to keep TestUnit tests around you're done, otherwise...

in the engine's Rakefile remove these tasks

require 'rake/testtask'

Rake::TestTask.new(:test) do |t|
  t.libs << 'lib'
  t.libs << 'test'
  t.pattern = 'test/**/*_test.rb'
  t.verbose = false
end

delete test dir

rm -rf test

check in

git commit -am"removed testunit tests"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment