testowl 0.0.9 → 0.1.0

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/bin/testowl CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'rubygems'
3
3
  require 'testowl'
4
+ require 'optparse'
4
5
  require 'active_support/inflector'
5
6
 
6
7
  $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') unless $LOAD_PATH.include?(File.dirname(__FILE__) + '/../lib')
@@ -8,7 +9,19 @@ CONFIG = File.dirname(__FILE__) + '/../lib/testowl/config.rb'
8
9
 
9
10
 
10
11
  begin
11
- success = Testowl::Monitor.new.run
12
+ options = {}
13
+ OptionParser.new do|opts|
14
+ opts.banner = "Usage: testowl [options]"
15
+ options[:just_tests] = false
16
+ opts.on('-j', '--just-tests', "Just run tests, no heuristics") do |v|
17
+ options[:just_tests] = v
18
+ end
19
+ opts.on( '-h', '--help', 'Display this screen' ) do
20
+ puts opts
21
+ exit
22
+ end
23
+ end.parse!
24
+ success = Testowl::Monitor.new(options).run
12
25
  Kernel.exit 1 unless success
13
26
  rescue SystemExit => e
14
27
  Kernel.exit(e.status)
data/lib/testowl/growl.rb CHANGED
@@ -3,7 +3,7 @@ module Testowl
3
3
 
4
4
  Growlnotify = "growlnotify"
5
5
 
6
- def self.grr(title, message, seconds, status, files, suffix)
6
+ def self.grr(title, message, seconds, status, files, suffix, identifier)
7
7
  project = File.expand_path(".").split("/").last
8
8
  growlnotify = `which #{Growlnotify}`.chomp
9
9
  if growlnotify == ''
@@ -17,12 +17,12 @@ module Testowl
17
17
  message_lines = [message.gsub("'", "`")]
18
18
  message_lines << sprintf("(%0.1f seconds)", seconds) if seconds
19
19
  message_lines << "#{files.map{|file| file.sub(/^spec\/[^\/]*\//, '').sub(/_test.rb$/, '')}.join("\n")}\n#{suffix}"
20
+ message_lines << identifier
20
21
  options = []
21
22
  options << "-n Watchr"
22
23
  options << "--message '#{message_lines.join("\n\n")}'"
23
- options << "--sticky" if status == :error
24
24
  options << "--image '#{image_path(status)}'"
25
- options << "--identifier #{Digest::MD5.hexdigest files.join}" # (used for coalescing)
25
+ options << "--identifier #{identifier}" # (used for coalescing)
26
26
  title = "TestOwl #{title} (#{project})"
27
27
  system %(#{growlnotify} #{options.join(' ')} '#{title}' &)
28
28
  puts message
@@ -3,7 +3,8 @@ module Testowl
3
3
 
4
4
  attr_reader :test_dir, :test_suffix
5
5
 
6
- def initialize()
6
+ def initialize(options)
7
+ @options = options
7
8
  if File.exist?("spec/spec_helper.rb")
8
9
  @runner = RspecRunner.new
9
10
  @test_dir = "spec"
@@ -23,18 +24,29 @@ module Testowl
23
24
  script = Watchr::Script.new
24
25
  # Watch the scripts themselves
25
26
  script.watch("#{test_dir}/.*/*_#{test_suffix}\.rb") do |match|
27
+ system("clear")
26
28
  puts "Detected change in #{match[0]}"
27
29
  run_test(match[0])
28
30
  end
29
31
  # Watch models
30
32
  script.watch("app/models/(.*)\.rb") do |match|
31
- puts "Detected change in #{match[0]}"
32
- run_model(match[1], "triggered by #{match[0]}")
33
+ if @options[:just_tests]
34
+ puts "Ignoring change in #{match[0]}"
35
+ else
36
+ system("clear")
37
+ puts "Detected change in #{match[0]}"
38
+ run_model(match[1], "triggered by #{match[0]}")
39
+ end
33
40
  end
34
41
  # Watch controllers
35
42
  script.watch("app/controllers/(.*)_controller\.rb") do |match|
36
- puts "Detected change in #{match[0]}"
37
- run_controller(match[1], "triggered by #{match[0]}")
43
+ if @options[:just_tests]
44
+ puts "Ignoring change in #{match[0]}"
45
+ else
46
+ system("clear")
47
+ puts "Detected change in #{match[0]}"
48
+ run_controller(match[1], "triggered by #{match[0]}")
49
+ end
38
50
  end
39
51
  puts "Waiting for code changes..."
40
52
  Watchr::Controller.new(script, Watchr.handler.new).run
@@ -12,6 +12,10 @@ module Testowl
12
12
  @files_list << array unless array.empty?
13
13
  end
14
14
 
15
+ def identifier
16
+ Digest::MD5.hexdigest @files_list.flatten.join
17
+ end
18
+
15
19
  def run
16
20
  test_count = 0
17
21
  fail_count = 0
@@ -20,8 +24,8 @@ module Testowl
20
24
  begin
21
25
  @files_list.each do |files|
22
26
  puts "Running #{files.inspect}"
23
- result = @runner.run(files)
24
27
  files_run += files
28
+ result = @runner.run(files)
25
29
  test_count += result[0]
26
30
  fail_count += result[1]
27
31
  seconds += result[2]
@@ -30,17 +34,17 @@ module Testowl
30
34
  if @files_list.empty?
31
35
  puts "No tests found"
32
36
  elsif test_count == 0
33
- Growl.grr "Empty Test", "No tests run", seconds, :error, files_run, @reason
37
+ Growl.grr "Empty Test", "No tests run", seconds, :error, files_run, @reason, identifier
34
38
  return false
35
39
  elsif fail_count > 0
36
- Growl.grr "Fail", "#{fail_count} out of #{test_count} test#{'s' if test_count > 1} failed :(", seconds, :failed, files_run, @reason
40
+ Growl.grr "Fail", "#{fail_count} out of #{test_count} test#{'s' if test_count > 1} failed :(", seconds, :failed, files_run, @reason, identifier
37
41
  return false
38
42
  else
39
- Growl.grr "Pass", "All #{test_count} example#{'s' if test_count > 1} passed :)", seconds, :success, files_run, @reason
43
+ Growl.grr "Pass", "All #{test_count} example#{'s' if test_count > 1} passed :)", seconds, :success, files_run, @reason, identifier
40
44
  return true
41
45
  end
42
46
  rescue => exc
43
- Growl.grr "Exception", exc.message, nil, :error, files_run, @reason
47
+ Growl.grr "Exception", exc.message, nil, :error, files_run, @reason, identifier
44
48
  end
45
49
  end
46
50
 
@@ -1,3 +1,3 @@
1
1
  module Testowl
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,61 +1,46 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: testowl
3
- version: !ruby/object:Gem::Version
4
- hash: 13
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 9
10
- version: 0.0.9
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Bill Horsman
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-07-01 00:00:00 -07:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 3
28
- segments:
29
- - 0
30
- version: "0"
31
- prerelease: false
32
- type: :runtime
33
- requirement: *id001
12
+ date: 2012-02-02 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
34
15
  name: watchr
35
- - !ruby/object:Gem::Dependency
36
- version_requirements: &id002 !ruby/object:Gem::Requirement
16
+ requirement: &70318555640140 !ruby/object:Gem::Requirement
37
17
  none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- hash: 3
42
- segments:
43
- - 0
44
- version: "0"
45
- prerelease: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
46
22
  type: :runtime
47
- requirement: *id002
23
+ prerelease: false
24
+ version_requirements: *70318555640140
25
+ - !ruby/object:Gem::Dependency
48
26
  name: rails
27
+ requirement: &70318555639640 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70318555639640
49
36
  description: TestUnit/RSpec, Watchr and Growl Integration for Continuous Testing
50
- email:
37
+ email:
51
38
  - bill@logicalcobwebs.com
52
- executables:
39
+ executables:
53
40
  - testowl
54
41
  extensions: []
55
-
56
42
  extra_rdoc_files: []
57
-
58
- files:
43
+ files:
59
44
  - Gemfile
60
45
  - README.markdown
61
46
  - Rakefile
@@ -73,39 +58,34 @@ files:
73
58
  - lib/testowl/tester.rb
74
59
  - lib/testowl/version.rb
75
60
  - testowl.gemspec
76
- has_rdoc: true
77
61
  homepage: https://github.com/billhorsman/testowl
78
62
  licenses: []
79
-
80
63
  post_install_message:
81
64
  rdoc_options: []
82
-
83
- require_paths:
65
+ require_paths:
84
66
  - lib
85
- required_ruby_version: !ruby/object:Gem::Requirement
67
+ required_ruby_version: !ruby/object:Gem::Requirement
86
68
  none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- hash: 3
91
- segments:
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ segments:
92
74
  - 0
93
- version: "0"
94
- required_rubygems_version: !ruby/object:Gem::Requirement
75
+ hash: -4322040739528282819
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
77
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 3
100
- segments:
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ segments:
101
83
  - 0
102
- version: "0"
84
+ hash: -4322040739528282819
103
85
  requirements: []
104
-
105
86
  rubyforge_project:
106
- rubygems_version: 1.5.0
87
+ rubygems_version: 1.8.10
107
88
  signing_key:
108
89
  specification_version: 3
109
90
  summary: TestUnit/RSpec, Watchr and Growl Integration for Continuous Testing
110
91
  test_files: []
111
-