Created
December 14, 2010 17:09
-
-
Save rgo/740716 to your computer and use it in GitHub Desktop.
Autotest for RSpec and Cucumber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Autotest::GnomeNotify | |
# Time notification will be displayed before disappearing automatically | |
EXPIRATION_IN_SECONDS = 3 | |
ERROR_STOCK_ICON = "gtk-cancel" | |
WARNING_STOCK_ICON = "gtk-dialog-warning" | |
SUCCESS_STOCK_ICON = "gtk-ok" | |
# Convenience method to send an error notification message | |
# | |
# [stock_icon] Stock icon name of icon to display | |
# [title] Notification message title | |
# [message] Core message for the notification | |
def self.notify stock_icon, title, message | |
options = "-t #{EXPIRATION_IN_SECONDS * 1000} -i #{stock_icon}" | |
system "notify-send #{options} '#{title}' '#{message}'" | |
end | |
Autotest.add_hook :red do |at| | |
notify ERROR_STOCK_ICON, "Tests failed", "#{at.files_to_test.size} tests failed" | |
end | |
Autotest.add_hook :green do |at| | |
notify SUCCESS_STOCK_ICON, "All tests passed, good job!", "" | |
end | |
Autotest.add_hook :ran_features do |autotest| | |
gist = autotest.results.grep(/\d+\s+scenario.*\)/).join(" / ").strip() | |
if gist == '' | |
notify ERROR_STOCK_ICON, "Cannot run features", "" | |
else | |
if gist =~ /([1-9]\d*)\s+failed/ | |
notify ERROR_STOCK_ICON, "Some features failed", "#{$1} failed" | |
elsif gist =~ /([1-9]\d*)\s+undefined/ | |
notify WARNING_STOCK_ICON, "Some features are undefined", "#{$1} undefined" | |
elsif gist =~ /([1-9]\d*)\s+pending/ | |
notify WARNING_STOCK_ICON, "Some features are pending", "#{$1} pending" | |
else | |
notify SUCCESS_STOCK_ICON, "All features passed, good job!", "" | |
end | |
end | |
end | |
Autotest.add_hook :initialize do |autotest| | |
%w{.git .svn .hg .DS_Store db log tmp vendor ._* .sqlite3 rerun.txt}.each do |exception| | |
autotest.add_exception(exception) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment