Commit 4e2cb5a
Changed files (4)
src/test/GreetingSpecs.cs
@@ -3,43 +3,43 @@
using Machine.Specifications;
using domain;
- public class GreetingSpecs
+ public class GreetingSpecs
+ {
+ Establish context = () =>
{
- Establish context = () =>
- {
- sut = new Greeting();
- };
-
- public class when_greeting_someone
- {
- Because of = () =>
- {
- result = sut.Hello();
- };
-
- It should_say_hello = () =>
- {
- result.ShouldEqual("hello");
- };
-
- static string result;
- }
-
- public class when_saying_goodbye
- {
- Because of = () =>
- {
- result = sut.Goodbye();
- };
-
- It should_say_goodbye = () =>
- {
- result.ShouldEqual("goodbye");
- };
-
- static string result;
- }
-
- static Greeting sut;
+ sut = new Greeting();
+ };
+
+ public class when_greeting_someone
+ {
+ Because of = () =>
+ {
+ result = sut.Hello();
+ };
+
+ It should_say_hello = () =>
+ {
+ result.ShouldEqual("hello");
+ };
+
+ static string result;
+ }
+
+ public class when_saying_goodbye
+ {
+ Because of = () =>
+ {
+ result = sut.Goodbye();
+ };
+
+ It should_say_goodbye = () =>
+ {
+ result.ShouldEqual("goodbye");
+ };
+
+ static string result;
}
+
+ static Greeting sut;
+ }
}
continuous_testing
@@ -0,0 +1,104 @@
+#!/usr/bin/env ruby
+require 'ruby_gntp'
+
+@all_files ={}
+
+class ChangedFile
+ attr_accessor :name,:last_changed_time
+
+ def initialize(name)
+ @name = name
+ @last_changed_time = File.mtime(name)
+ end
+
+ def has_changed?
+ @last_changed_time < File.mtime(@name)
+ end
+
+ def update
+ @last_changed_time = File.mtime(@name)
+ end
+
+ def was_deleted?
+ not File.exists?(@name)
+ end
+end
+
+
+class BuildMessage
+ def initialize(error_items)
+ @error_items = error_items
+ end
+
+ def successful
+ @error_items.length == 0
+ end
+
+ def message
+ successful ? "Build Successful" : @error_items.join("\r\n")
+ end
+end
+
+
+def scan_for_new_files
+ has_new_files = false
+ Dir.glob("**/*.cs").each do|file|
+ unless (@all_files.key?(file))
+ has_new_files = true
+ @all_files[file] = ChangedFile.new(file)
+ end
+ end
+ has_new_files
+end
+
+def remove_all_deleted
+ remaining = @all_files.select{|path,item| ! item.was_deleted?}
+ files_were_deleted = remaining.length != @all_files.length
+ @all_files = remaining
+ files_were_deleted
+end
+
+def changes_have_occured
+ return scan_for_new_files | remove_all_deleted | files_have_changed
+end
+
+def files_have_changed
+ has_changed = false
+ @all_files.each do|path,file|
+ has_changed |= file.has_changed?
+ file.update
+ end
+ return has_changed
+end
+
+def get_errors_in(output)
+ error_pattern = /error|FAIL/
+ output.split("\n").select{|item| error_pattern =~ item}
+end
+
+def notify(build_message)
+ #icon = build_message.successful ? "green" : "red"
+ #args = {:t => "Build",:i => ".\\#{icon}.jpg"}
+ #command_line = "build/tools/growl/growlnotify.exe"
+ #args.each {|key,value| command_line += " /#{key}:\"#{value}\""}
+ #`#{command_line} "#{build_message.message}"`
+
+ GNTP.notify({
+ :app_name => 'c# practice',
+ :title => build_message.successful ? 'PASS' : 'FAIL',
+ :text => build_message.message,
+ :icon => build_message.successful ? 'green.jpg' : 'red.jpg'
+ })
+end
+
+def monitor
+ if changes_have_occured
+ errors = get_errors_in(`rake spec`)
+ notify(BuildMessage.new(errors))
+ end
+end
+
+while true do
+ monitor
+ sleep(1)
+end
Gemfile
@@ -1,4 +1,7 @@
source 'http://rubygems.org'
+gem 'rake'
gem 'albacore'
-gem 'rubyzip'
+gem 'configatron'
+gem 'ruby_gntp'
+#gem 'rubyzip'
Gemfile.lock
@@ -3,11 +3,18 @@ GEM
specs:
albacore (0.2.7)
rubyzip (~> 0.9)
+ configatron (2.9.0)
+ yamler (>= 0.1.0)
+ rake (0.9.2.2)
+ ruby_gntp (0.3.4)
rubyzip (0.9.5)
+ yamler (0.1.0)
PLATFORMS
ruby
DEPENDENCIES
albacore
- rubyzip
+ configatron
+ rake
+ ruby_gntp