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