Skip to content

Instantly share code, notes, and snippets.

@rohinomiya
Created September 3, 2011 20:40
Show Gist options
  • Save rohinomiya/1191756 to your computer and use it in GitHub Desktop.
Save rohinomiya/1191756 to your computer and use it in GitHub Desktop.
sample of AuutoTest configuration file
# -*- ruby -*-
require 'autotest/growl'
Autotest.add_discovery { "rspec" }
# ./foo.rb が更新されると ./spec/foo_spec.rb が走る。
Autotest.add_hook :initialize do |at|
at.add_mapping(/([\w\d_]+)\.rb$/) {|f, matched|
"spec/#{matched[1]}_spec.rb"
}
end
# 何故か2重にポップアップが表示されてうざいので、適当にクリアーした
class Autotest
def self.clear_hook
HOOKS[:red].clear
HOOKS[:green].clear
HOOKS[:all_good].clear
end
end
Autotest.clear_hook
ICON_FAILURE = "rails_fail"
ICON_SUCCESS = "rails_ok"
module Autotest::Growl
Autotest.add_hook :ran_command do |at|
results = at.results.last
examples = results[/(\d+)\s+examples?/].to_i # テストの総数
failures = results[/(\d+)\s+failures?/].to_i # 失敗の数
errors = results[/(\d+)\s+errors?/].to_i # エラーの数
if examples >= 0
if failures > 0 || errors > 0
growl "Tests Failed", "#{results}",ICON_FALURE, 2 #, true
else
growl "Tests Passed", "#{results}",ICON_SUCCESS, -2
end
else
growl "Tests Error", "Some ploblem occurred.",ICON_FAILURE, 2, true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment