minor refactoring

This commit is contained in:
Sam 2013-08-06 06:34:42 +10:00
parent 11dca1fd92
commit 628ec101c7
1 changed files with 25 additions and 22 deletions

View File

@ -19,7 +19,7 @@ class Autospec::Runner
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" } watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" } watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('app/controllers/application_controller.rb') { "spec/controllers" } watch("app/controllers/application_controller.rb") { "spec/controllers" }
# Capybara request specs # Capybara request specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" } watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
@ -85,27 +85,7 @@ class Autospec::Runner
end end
while spork_running while spork_running
process_queue
STDIN.gets
if @queue.length == 0
@queue << ['spec', 'spec']
@signal.signal
else
specs = failed_specs(:delete => false)
puts
puts
if specs.length == 0
puts "No specs have failed yet!"
puts
else
puts "The following specs have failed: "
specs.each do |s|
puts s
end
puts
end
end
end end
puts "Spork has been terminated, exiting" puts "Spork has been terminated, exiting"
@ -116,6 +96,29 @@ class Autospec::Runner
stop_spork stop_spork
end end
def process_queue
STDIN.gets
if @queue.length == 0
@queue << ['spec', 'spec']
@signal.signal
else
specs = failed_specs(:delete => false)
puts
puts
if specs.length == 0
puts "No specs have failed yet!"
puts
else
puts "The following specs have failed: "
specs.each do |s|
puts s
end
puts
end
end
end
def wait_for(timeout_milliseconds) def wait_for(timeout_milliseconds)
timeout = (timeout_milliseconds + 0.0) / 1000 timeout = (timeout_milliseconds + 0.0) / 1000
finish = Time.now + timeout finish = Time.now + timeout