Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Various enhancments:

* Allow backtrace to show in test output.
* Make run faster skipping more if dummy app already generated
* Re-ordered some methods to be more logical.
  • Loading branch information...
commit 2acb5d1e1288f83975654eabcdd8cd67a50ed605 1 parent 1424d74
@eric1234 authored
View
1  .gitignore
@@ -0,0 +1 @@
+pkg
View
47 lib/test_engine.rb
@@ -21,35 +21,31 @@ class TestEngine < Rake::TaskLib
# Define the "generate" task which will generate a dummy Rails app when ran.
def install_generate
task 'test:engine:generate' do
- # Some info for the app template
- env = {
- 'ENGINE_NAME' => engine_name,
- 'OLDPWD' => Dir.pwd,
- 'DEV_DEPS' => (development_dependencies - ['test_engine']).join(','),
- }
+ unless app_path.exist?
- clean_sh %Q!
- #{rails_stub} _#{rails_version}_ new #{app_path}
- --skip-bundle -f -m #{template_path}
- !, env unless app_path.exist?
- end
- end
+ # Some info for the app template
+ env = {
+ 'ENGINE_NAME' => engine_name,
+ 'ENGINE_PATH' => Dir.pwd,
+ 'DEV_DEPS' => (development_dependencies - ['test_engine']).join(','),
+ }
- # Define the "clean" task which will remove dummy Rails apps when ran.
- def install_clean
- desc 'Remove dummy test apps. RAILS_VERSION to remove specific version'
- task 'test:engine:clean' do
- rails_version = ENV['RAILS_VERSION'] || '*'
- rm_rf Dir["tmp/dummy_apps/v#{rails_version}"], :verbose => false
+ clean_sh %Q!
+ #{rails_stub} _#{rails_version}_ new #{app_path}
+ --skip-bundle -f -m #{template_path}
+ !, env
+ end
end
end
# Define the "setup" task that will load any engine migrations and seed data
def install_setup
task 'test:engine:setup' => 'test:engine:generate' do
- clean_sh 'bundle install --quiet', {'BUNDLE_GEMFILE' => gemfile_path}, true
- rake "railties:install:migrations"
- rake "db:migrate", 'RAILS_ENV' => 'test'
+ unless app_path.exist?
+ clean_sh 'bundle install --quiet', {'BUNDLE_GEMFILE' => gemfile_path}, true
+ rake "railties:install:migrations"
+ rake "db:migrate", 'RAILS_ENV' => 'test'
+ end
end
end
@@ -62,6 +58,15 @@ def install_env
end
end
+ # Define the "clean" task which will remove dummy Rails apps when ran.
+ def install_clean
+ desc 'Remove dummy test apps. RAILS_VERSION to remove specific version'
+ task 'test:engine:clean' do
+ rails_version = ENV['RAILS_VERSION'] || '*'
+ rm_rf Dir["tmp/dummy_apps/v#{rails_version}"], :verbose => false
+ end
+ end
+
# So user can refer to 'test:engine' instead of 'test:engine:generate'.
# NOTE: This method MUST be later alphabetically than install_generate.
def install_shortcut
View
9 share/template.rb
@@ -1,8 +1,13 @@
# Add the engine being tested to the app.
-gem ENV['ENGINE_NAME'], :path => ENV['OLDPWD']
+gem ENV['ENGINE_NAME'], :path => ENV['ENGINE_PATH']
# All development dependencies of the engine should be added to the app
# as they might be used in testing.
for dep in ENV['DEV_DEPS'].split(',')
gem dep
-end
+end
+
+# So you can see backtraces in your engine
+append_file 'config/initializers/backtrace_silencers.rb', <<SILENCE
+ Rails.backtrace_cleaner.add_filter {|line| line.sub "#{ENV['ENGINE_PATH']}/", '' }
+SILENCE
View
2  test_engine.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'test_engine'
- s.version = '0.0.2'
+ s.version = '0.0.3'
s.author = 'Eric Anderson'
s.email = 'eric@pixelwareinc.com'
s.add_dependency 'rails', '> 3'
Please sign in to comment.
Something went wrong with that request. Please try again.