From 9552d1d2c5d9a18ef8591b5467f1c29c330c8f14 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 14 Feb 2012 09:28:28 -0500 Subject: [PATCH] rake tasks --- README.md | 8 ++++++++ lib/vegetable_glue.rb | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/README.md b/README.md index 23e2a6e..03e2ef4 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,12 @@ In the consumer (Frontend): ``` ruby require 'vegetable_glue/cucumber' +``` + +* Then add this to the `config/environments/.rb` file that Cucumbers runs under: + +``` ruby +require 'vegetable_glue' VegetableGlue.url = 'http://localhost:6161/' #=> include the port in here, too, that's where the app will run VegetableGlue.path = '../path/to/the/app' @@ -44,6 +50,8 @@ The app will clean its database on each scenario. To restart the app, pass in th REGLUE=true bundle exec cucumber +Or, use one of the Rake tasks: `vegetable:unglue` to shut down and `vegetable:reglue` to shutdown, then clean. + If you're using ActiveResource, a good source of the URL is `ActiveResource::Base.site`. ## Contributing diff --git a/lib/vegetable_glue.rb b/lib/vegetable_glue.rb index af5a102..17496e3 100644 --- a/lib/vegetable_glue.rb +++ b/lib/vegetable_glue.rb @@ -28,5 +28,24 @@ module VegetableGlue { :url => url, :path => path, :env => env } end end + + if defined?(::Rails) && defined?(::Rails::Railtie) + class Railtie < ::Rails::Railtie + rake_tasks do + self.class.send(:include, Rake::DSL) + + desc "Stop the dependent application" + task "vegetable:unglue" => :environment do + VegetableGlue.shutdown + end + + desc "Restart the dependent application" + task "vegetable:reglue" => :environment do + VegetableGlue.shutdown + VegetableGlue.clean + end + end + end + end end