Permalink
Browse files

Make running specs easier.

  • Loading branch information...
1 parent 036b50e commit 032e96d696d809c8eed529ea1102ea7a353cc24a @phiggins phiggins committed Mar 30, 2012
Showing with 19 additions and 12 deletions.
  1. +2 −0 Rakefile
  2. +2 −0 tasks/rspec.rake
  3. +15 −12 testing/lib/refinery/tasks/testing.rake
View
@@ -21,3 +21,5 @@ Refinery::Testing::Railtie.load_dummy_tasks(File.dirname(__FILE__))
desc "Build gem files for all projects"
task :build => "all:build"
+
+task :default => :spec
View
@@ -4,3 +4,5 @@ desc "Run specs"
RSpec::Core::RakeTask.new do |t|
t.pattern = "./*/spec"
end
+
+task :spec => "refinery:testing:conditionally_setup_dummy_app"
@@ -1,7 +1,7 @@
namespace :refinery do
namespace :testing do
desc "Generates a dummy app for testing"
- task :dummy_app => [:setup_dummy_app, :setup_extension, "extension:setup"]
+ task :dummy_app => [:setup_dummy_app, :setup_extension, :init_test_database]
task :setup_dummy_app do
require 'refinerycms'
@@ -12,6 +12,8 @@ namespace :refinery do
Refinery::DummyGenerator.start params
Refinery::CmsGenerator.start %w[--quiet --fresh-installation]
+
+ Dir.chdir Refinery::Testing::Railtie.target_extension_path
end
# This task is a hook to allow extensions to pass configuration
@@ -31,21 +33,22 @@ namespace :refinery do
desc "Remove the dummy app used for testing"
task :clean_dummy_app do
- path = Refinery::Testing::Railtie.target_extension_path.join('spec', 'dummy')
-
- path.rmtree if path.exist?
+ dummy_app_path.rmtree if dummy_app_path.exist?
end
- namespace :extension do
- desc "Initialize the testing environment"
- task :setup => [:init_test_database]
-
- task :init_test_database do
- task_params = [%Q{ bundle exec rake -f #{Refinery::Testing::Railtie.target_extension_path.join('Rakefile')} }]
- task_params << %Q{ app:db:test:prepare }
+ task :init_test_database do
+ load 'rails/tasks/engine.rake'
+ Rake::Task["app:db:test:prepare"].invoke
+ end
- system task_params.join(' ')
+ task :conditionally_setup_dummy_app do
+ unless dummy_app_path.exist?
+ Rake::Task["refinery:testing:dummy_app"].invoke
end
end
+
+ def dummy_app_path
+ Refinery::Testing::Railtie.target_extension_path.join('spec', 'dummy')
+ end
end
end

0 comments on commit 032e96d

Please sign in to comment.