testowl 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/testowl/growl.rb CHANGED
@@ -20,7 +20,7 @@ module Testowl
20
20
  options << "--sticky" if status == :error
21
21
  options << "--image '#{image_path(status)}'"
22
22
  options << "--identifier #{Digest::MD5.hexdigest files.join}" # (used for coalescing)
23
- title = "RSpec #{title} (#{project})"
23
+ title = "TestOwl #{title} (#{project})"
24
24
  system %(#{growlnotify} #{options.join(' ')} '#{title}' &)
25
25
  puts message
26
26
  end
@@ -22,37 +22,28 @@ module Testowl
22
22
  # Watch the scripts themselves
23
23
  script.watch("#{test_dir}/.*/*_#{test_suffix}\.rb") do |match|
24
24
  puts "Detected change in #{match[0]}"
25
- fire [match[0]], "has been updated"
25
+ run_test(match[0])
26
26
  end
27
27
  # Watch models
28
28
  script.watch("app/models/(.*)\.rb") do |match|
29
29
  puts "Detected change in #{match[0]}"
30
- tests = []
31
- model = match[1]
32
- tests += tests_for_model(model)
33
- fire tests, "triggered by #{match[0]}"
30
+ run_model(match[1], "triggered by #{match[0]}")
34
31
  end
35
32
  puts "Monitoring files..."
36
33
  Watchr::Controller.new(script, Watchr.handler.new).run
37
34
  end
38
35
 
39
- def fire(files, reason)
40
- return if files.nil? || files.size == 0
41
- # We don't want to do no performance testing
42
- files = files.map{|file| file =~ /^test\/performance\// ? nil : file }.compact
43
- puts "Running #{files.join(", ")}"
44
- begin
45
- test_count, fail_count, timing = @runner.run(files)
46
- if test_count == 0
47
- Growl.grr "Empty Test", "No tests run", :error, files, reason
48
- elsif fail_count > 0
49
- Growl.grr "Fail", "#{fail_count} out of #{test_count} test#{'s' if test_count > 1} failed in #{timing} :(", :failed, files, reason
50
- else
51
- Growl.grr "Pass", "All #{test_count} example#{'s' if test_count > 1} passed in #{timing} :)", :success, files, reason
52
- end
53
- rescue => exc
54
- Growl.grr "Exception", exc.message, :error, files, reason
55
- end
36
+ def run_test(file)
37
+ tester = Tester.new(@runner, "has been updated")
38
+ tester.add file
39
+ tester.run
40
+ end
41
+
42
+ def run_model(model_name, reason)
43
+ tester = Tester.new(@runner, reason)
44
+ tester.add Dir["#{test_dir}/**/#{model_name}_#{test_suffix}.rb"]
45
+ tester.add Dir["#{test_dir}/**/#{model_name.pluralize}_controller_#{test_suffix}.rb"]
46
+ tester.run
56
47
  end
57
48
 
58
49
  def tests_for_model(model)
@@ -19,7 +19,7 @@ module Testowl
19
19
  if exception_message
20
20
  raise exception_message
21
21
  else
22
- raise "Problem interpreting output"
22
+ raise "Problem interpreting result. Please check the terminal output."
23
23
  end
24
24
  end
25
25
  end
@@ -35,7 +35,7 @@ module Testowl
35
35
  raise exception_message
36
36
  else
37
37
  $stderr.print results
38
- raise "Problem interpreting output"
38
+ raise "Problem interpreting result. Please check the terminal output."
39
39
  end
40
40
  end
41
41
  end
@@ -0,0 +1,42 @@
1
+ module Testowl
2
+ class Tester
3
+
4
+ def initialize(runner, reason)
5
+ @runner = runner
6
+ @reason = reason
7
+ @files_list = []
8
+ end
9
+
10
+ def add(files)
11
+ @files_list << [files].flatten
12
+ end
13
+
14
+ def run
15
+ test_count = 0
16
+ fail_count = 0
17
+ files_run = []
18
+ begin
19
+ @files_list.each do |files|
20
+ result = @runner.run(files)
21
+ files_run += files
22
+ test_count += result[0]
23
+ fail_count += result[1]
24
+ break if fail_count > 0
25
+ end
26
+ if test_count == 0
27
+ Growl.grr "Empty Test", "No tests run", :error, files_run, @reason
28
+ return false
29
+ elsif fail_count > 0
30
+ Growl.grr "Fail", "#{fail_count} out of #{test_count} test#{'s' if test_count > 1} failed :(", :failed, files_run, @reason
31
+ return false
32
+ else
33
+ Growl.grr "Pass", "All #{test_count} example#{'s' if test_count > 1} passed :)", :success, files_run, @reason
34
+ return true
35
+ end
36
+ rescue => exc
37
+ Growl.grr "Exception", exc.message, :error, files_run, @reason
38
+ end
39
+ end
40
+
41
+ end
42
+ end
@@ -1,3 +1,3 @@
1
1
  module Testowl
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/testowl.rb CHANGED
@@ -2,6 +2,7 @@ require 'testowl/growl'
2
2
  require 'testowl/monitor'
3
3
  require 'testowl/rspec_runner'
4
4
  require 'testowl/test_unit_runner'
5
+ require 'testowl/tester'
5
6
  require 'testowl/version'
6
7
  require 'watchr'
7
8
  require 'digest'
data/testowl.gemspec CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Bill Horsman"]
10
10
  s.email = ["bill@logicalcobwebs.com"]
11
- s.homepage = ""
12
- s.summary = %q{TestUnit, Watchr and Growl Integration for Continuous Testing}
13
- s.description = %q{TestUnit, Watchr and Growl Integration for Continuous Testing}
11
+ s.homepage = "https://github.com/billhorsman/testowl"
12
+ s.summary = %q{TestUnit/RSpec, Watchr and Growl Integration for Continuous Testing}
13
+ s.description = %q{TestUnit/RSpec, Watchr and Growl Integration for Continuous Testing}
14
14
 
15
15
  s.add_runtime_dependency "watchr"
16
16
  s.add_runtime_dependency "rails"
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
29
29
  "lib/testowl/monitor.rb",
30
30
  "lib/testowl/rspec_runner.rb",
31
31
  "lib/testowl/test_unit_runner.rb",
32
+ "lib/testowl/tester.rb",
32
33
  "lib/testowl/version.rb",
33
34
  "testowl.gemspec"
34
35
  ]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testowl
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bill Horsman
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-14 00:00:00 -07:00
18
+ date: 2011-06-21 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -46,7 +46,7 @@ dependencies:
46
46
  type: :runtime
47
47
  requirement: *id002
48
48
  name: rails
49
- description: TestUnit, Watchr and Growl Integration for Continuous Testing
49
+ description: TestUnit/RSpec, Watchr and Growl Integration for Continuous Testing
50
50
  email:
51
51
  - bill@logicalcobwebs.com
52
52
  executables:
@@ -69,10 +69,11 @@ files:
69
69
  - lib/testowl/monitor.rb
70
70
  - lib/testowl/rspec_runner.rb
71
71
  - lib/testowl/test_unit_runner.rb
72
+ - lib/testowl/tester.rb
72
73
  - lib/testowl/version.rb
73
74
  - testowl.gemspec
74
75
  has_rdoc: true
75
- homepage: ""
76
+ homepage: https://github.com/billhorsman/testowl
76
77
  licenses: []
77
78
 
78
79
  post_install_message:
@@ -104,6 +105,6 @@ rubyforge_project:
104
105
  rubygems_version: 1.5.0
105
106
  signing_key:
106
107
  specification_version: 3
107
- summary: TestUnit, Watchr and Growl Integration for Continuous Testing
108
+ summary: TestUnit/RSpec, Watchr and Growl Integration for Continuous Testing
108
109
  test_files: []
109
110