make some things nicer
This commit is contained in:
parent
62af16c465
commit
24f2bf7965
@ -15,8 +15,8 @@ module VegetableGlue
|
||||
Runner.new(options).shutdown
|
||||
end
|
||||
|
||||
def clean
|
||||
Runner.new(options).clean
|
||||
def clean(name = nil)
|
||||
Runner.new(options).clean(name)
|
||||
end
|
||||
|
||||
def env
|
||||
@ -30,4 +30,3 @@ module VegetableGlue
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
Before do
|
||||
Before do |scenario|
|
||||
if ENV['REGLUE']
|
||||
VegetableGlue.shutdown
|
||||
|
||||
ENV.delete('REGLUE')
|
||||
end
|
||||
|
||||
VegetableGlue.clean
|
||||
VegetableGlue.clean(scenario.to_sexp[3])
|
||||
end
|
||||
|
||||
|
@ -12,6 +12,10 @@ class ActionDispatch::Routing::Mapper
|
||||
|
||||
DatabaseCleaner.clean_with :truncation
|
||||
|
||||
if scenario_name = URI.decode_www_form(env['QUERY_STRING']).first
|
||||
Rails.logger.info "Cleaning database for #{scenario_name.last}"
|
||||
end
|
||||
|
||||
[ 200, {}, [ VegetableGlue::CLEAN ] ]
|
||||
}
|
||||
end
|
||||
|
@ -10,9 +10,11 @@ module VegetableGlue
|
||||
port = options[:url].port
|
||||
|
||||
result = nil
|
||||
was_running = false
|
||||
|
||||
begin
|
||||
result = get_acceptance
|
||||
was_running = true
|
||||
rescue Errno::ECONNREFUSED => e
|
||||
$stdout.puts "Starting #{app_name}..."
|
||||
|
||||
@ -24,7 +26,7 @@ module VegetableGlue
|
||||
end
|
||||
|
||||
if result == VegetableGlue::ACCEPTANCE
|
||||
$stdout.puts "#{app_name} running on port #{port}"
|
||||
$stdout.puts "#{app_name} running on port #{port}" if !was_running
|
||||
else
|
||||
raise StandardError.new("Is #{app_name} running? You should have included the routes with `acceptance_helper_routes`")
|
||||
end
|
||||
@ -42,10 +44,13 @@ module VegetableGlue
|
||||
FileUtils.rm_f pid_path
|
||||
end
|
||||
|
||||
def clean
|
||||
def clean(name = nil)
|
||||
ensure_running
|
||||
|
||||
result = Net::HTTP.get(options[:url].merge(URI("/#{VegetableGlue::CLEAN}")))
|
||||
uri = options[:url].merge(URI("/#{VegetableGlue::CLEAN}"))
|
||||
uri.query = URI.encode_www_form(:scenario => name) if name
|
||||
|
||||
result = Net::HTTP.get(uri)
|
||||
|
||||
raise StandardError.new("#{app_name} database not cleaned") if result != VegetableGlue::CLEAN
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user