guard-test 0.1.2 → 0.1.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.
@@ -1,9 +1,11 @@
1
1
  = Guard::Test
2
2
 
3
- Test::Unit guard allows to automatically & intelligently launch tests when files are modified.
3
+ Guard::Test allows to automatically & intelligently launch tests when files are modified or created.
4
+
5
+ == Compatibility
4
6
 
5
7
  - Compatible with Test::Unit 2.1.1.
6
- - Tested on Ruby 1.8.6, 1.8.7, REE & 1.9.2 (display a annoying "uninitialized constant Test::Unit::UI::Console::Diff" warning though).
8
+ - Tested on Ruby 1.8.6, 1.8.7, REE & 1.9.2.
7
9
 
8
10
  == Install
9
11
 
@@ -11,67 +13,72 @@ Please be sure to have {guard}[http://github.com/guard/guard] installed before c
11
13
 
12
14
  Install the gem:
13
15
 
14
- gem install guard-test
16
+ gem install guard-test
15
17
 
16
18
  Add it to your Gemfile (inside test group):
17
19
 
18
- gem 'guard-test'
20
+ gem 'guard-test'
19
21
 
20
22
  Add guard definition to your Guardfile by running this command:
21
23
 
22
- guard init test
24
+ guard init test
23
25
 
24
26
  == Usage
25
27
 
26
- Please read {guard usage doc}[http://github.com/guard/guard#readme]
28
+ Please read {guard usage doc}[http://github.com/guard/guard#readme].
27
29
 
28
30
  == Guardfile
29
31
 
30
- Test::Unit guard can be really be adapted to all kind of projects.
32
+ Guard::Test can be adapted to many kind of projects.
31
33
  Please read {guard doc}[http://github.com/guard/guard#readme] for more info about Guardfile DSL.
32
34
 
33
- === Standard ruby gems
35
+ === Standard Ruby project
34
36
 
35
- guard 'test' do
36
- watch('^lib/(.*)\.rb') { |m| "test/lib/#{m[1]}_test.rb" }
37
- watch('^test/(.*)_test.rb')
38
- watch('^test/test_helper.rb') { "test" }
39
- end
37
+ guard 'test' do
38
+ watch('^lib/(.*)\.rb') { |m| "test/lib/#{m[1]}_test.rb" }
39
+ watch('^test/(.*)_test.rb')
40
+ watch('^test/test_helper.rb') { "test" }
41
+ end
40
42
 
41
- === Rails app
43
+ === Ruby On Rails project
42
44
 
43
- guard 'test' do
44
- watch('^app/models/(.*)\.rb') { |m| "test/unit/#{m[1]}_test.rb" }
45
- watch('^app/controllers/(.*)\.rb') { |m| "test/functional/#{m[1]}_test.rb" }
46
- watch('^app/controllers/application_controller.rb') { "test/functional" }
47
- watch('^app/controllers/application_controller.rb') { "test/integration" }
48
- watch('^app/views/(.*)\.rb') { "test/integration" }
49
- watch('^lib/(.*)\.rb') { |m| "test/lib/#{m[1]}_test.rb" }
50
- watch('^test/(.*)_test.rb')
51
- watch('^test/factories.rb') { "test/unit" }
52
- watch('^test/test_helper.rb') { "test" }
53
- end
45
+ guard 'test' do
46
+ watch('^app/models/(.*)\.rb') { |m| "test/unit/#{m[1]}_test.rb" }
47
+ watch('^app/controllers/(.*)\.rb') { |m| "test/functional/#{m[1]}_test.rb" }
48
+ watch('^app/controllers/application_controller.rb') { "test/functional" }
49
+ watch('^app/controllers/application_controller.rb') { "test/integration" }
50
+ watch('^app/views/(.*)\.rb') { "test/integration" }
51
+ watch('^lib/(.*)\.rb') { |m| "test/lib/#{m[1]}_test.rb" }
52
+ watch('^test/(.*)_test.rb')
53
+ watch('^test/factories.rb') { "test/unit" }
54
+ watch('^test/test_helper.rb') { "test" }
55
+ end
54
56
 
55
57
  == Options
56
58
 
57
- Test::Unit guard allow you to choose between two different runners:
58
-
59
- - 'default' (obviously, guard-test will use this by default): Display progress as chars ('.' for pass, 'F' for fail, 'E' for error) and errors when all the tests are finished.
60
- - 'fastfail': Display failures/errors messages as they happen, not at the end and passing tests with '.'.
59
+ Guard::Test allows you to choose between two different runners (Guard::Test's runners are inherited from Test::Unit's console runner):
60
+ - <tt>'default'</tt>: Display tests results as they happen, with different chars ('.' for pass, 'F' for fail, 'E' for error) and print failures/errors messages & backtraces when all the tests are finished. Obviously, this is the guard-test default.
61
+ - <tt>'fastfail'</tt>: Display tests results as they happen and print failures/errors messages & backtraces immediately.
61
62
 
62
- Set the desired runner by passing the :runner option to the <tt>guard</tt> method:
63
+ Set the desired runner by passing the <tt>:runner</tt> option to the <tt>guard</tt> method:
63
64
 
64
- guard 'test', :runner => 'fastfail' do
65
- ...
66
- end
65
+ guard 'test', :runner => 'fastfail' do
66
+ ...
67
+ end
67
68
 
68
69
  == Development
69
70
 
70
- - Source hosted at {GitHub}[http://github.com/guard/guard-test]
71
- - Report issues/Questions/Feature requests on {GitHub Issues}[http://github.com/guard/guard-test/issues]
71
+ - Source hosted on GitHub: http://github.com/guard/guard-test
72
+ - Report issues/Questions/Feature requests on GitHub Issues: http://github.com/guard/guard-test/issues
73
+
74
+ Pull requests are very welcome!
75
+ Make sure your patches are well tested.
76
+ Please create a topic branch for every separate change you make.
77
+
78
+ == Author
72
79
 
73
- Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change you make.
80
+ {Rémy Coutable}[http://github.com/rymai]
74
81
 
75
- == Authors
82
+ == Kudo
76
83
 
77
- {Rémy Coutable}[http://github.com/rymai]
84
+ Many thanks to {Thibaud Guillaume-Gentil}[http://github.com/thibaudgg] for creating the excellent Guard gem.
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'guard'
3
2
  require 'guard/guard'
4
3
 
@@ -1,11 +1,9 @@
1
- require "#{File.dirname(__FILE__)}/../test"
2
-
3
1
  module Formatter
4
2
 
5
- def output_results(test_count, assertion_count, failure_count, error_count, duration, options = {})
6
- output(duration_text(duration, options)) if options[:with_duration]
3
+ def print_results(test_count, assertion_count, failure_count, error_count, duration, options = {})
4
+ puts_with_color(duration_text(duration, options)) if options[:with_duration]
7
5
  color = (failure_count > 0 ? "failure" : (error_count > 0 ? "error" : "pass"))
8
- output(results_text(test_count, assertion_count, failure_count, error_count), color)
6
+ puts_with_color(results_text(test_count, assertion_count, failure_count, error_count), color)
9
7
  end
10
8
 
11
9
  def notify_results(test_count, assertion_count, failure_count, error_count, duration)
@@ -15,8 +13,8 @@ module Formatter
15
13
  )
16
14
  end
17
15
 
18
- def output_and_notify_results(test_count, assertion_count, failure_count, error_count, duration, options = {})
19
- output_results(test_count, assertion_count, failure_count, error_count, duration, options)
16
+ def print_and_notify_results(test_count, assertion_count, failure_count, error_count, duration, options = {})
17
+ print_results(test_count, assertion_count, failure_count, error_count, duration, options)
20
18
  notify_results(test_count, assertion_count, failure_count, error_count, duration)
21
19
  end
22
20
 
@@ -28,15 +26,15 @@ module Formatter
28
26
  Guard::Notifier.notify(message, :title => "Test::Unit results", :image => image)
29
27
  end
30
28
 
31
- def output_single(something, color_name = "reset")
29
+ def print_with_color(something, color_name = "reset")
32
30
  something = "%s%s%s" % [color_sequence(color_name), something, color_sequence("reset")]
33
31
  $stdout.write(something)
34
32
  $stdout.flush
35
33
  true
36
34
  end
37
35
 
38
- def output(something, color_name = "reset")
39
- output_single(something, color_name)
36
+ def puts_with_color(something, color_name = "reset")
37
+ print_with_color(something, color_name)
40
38
  $stdout.puts
41
39
  end
42
40
 
@@ -19,7 +19,7 @@ module Guard
19
19
  private
20
20
 
21
21
  def test_unit_command(files)
22
- cmd_parts = ["ruby"]
22
+ cmd_parts = ["ruby -rubygems"]
23
23
  cmd_parts << "-r#{File.dirname(__FILE__)}/runners/#{@test_unit_runner}_test_unit_runner"
24
24
  cmd_parts << "-Itest"
25
25
  cmd_parts << "-e \"%w[#{files.join(' ')}].each { |f| load f }\""
@@ -1,13 +1,14 @@
1
1
  require "#{File.dirname(__FILE__)}/../formatter"
2
+ require "#{File.dirname(__FILE__)}/../../test"
3
+ gem 'test-unit' if RUBY_VERSION =~ %r(1\.9\.2) # Thanks Aaron! http://redmine.ruby-lang.org/issues/show/3561
2
4
  require 'test/unit'
3
- require 'test/unit/testcase'
4
5
  require 'test/unit/ui/console/testrunner'
5
6
 
6
7
  # Thanks to Adam Sanderson for the really good starting point:
7
8
  # http://endofline.wordpress.com/2008/02/11/a-custom-testrunner-to-scratch-an-itch/
8
9
  #
9
10
  # This class inherits from Test::Unit' standard console TestRunner
10
- # I'm just overriding some callbacks methods to display nice results
11
+ # I'm just overriding some callbacks methods to display some nicer results
11
12
  class DefaultGuardTestRunner < Test::Unit::UI::Console::TestRunner
12
13
  include Formatter
13
14
 
@@ -32,12 +33,12 @@ protected
32
33
 
33
34
  def add_fault(fault)
34
35
  @faults << fault
35
- output_single(fault.single_character_display, fault_color_name(fault))
36
+ print_with_color(fault.single_character_display, fault_color_name(fault))
36
37
  @already_outputted = true
37
38
  end
38
39
 
39
40
  def test_finished(name)
40
- output_single(".", "pass") unless @already_outputted
41
+ print_with_color(".", "pass") unless @already_outputted
41
42
  @already_outputted = false
42
43
  end
43
44
 
@@ -11,12 +11,12 @@ private
11
11
  def add_fault(fault)
12
12
  @faults << fault
13
13
  nl
14
- output("%3d) %s" % [@faults.length, fault.long_display])
14
+ puts_with_color("%3d) %s" % [@faults.length, fault.long_display])
15
15
  @already_outputted = true
16
16
  end
17
17
 
18
18
  def finished(elapsed_time)
19
- output_and_notify_results(@result.run_count, @result.assertion_count, @result.failure_count, @result.error_count, elapsed_time, :with_duration => true)
19
+ print_and_notify_results(@result.run_count, @result.assertion_count, @result.failure_count, @result.error_count, elapsed_time, :with_duration => true)
20
20
  end
21
21
 
22
22
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module TestVersion
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-test
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - "R\xC3\xA9my Coutable"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-19 00:00:00 +02:00
18
+ date: 2010-10-26 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,10 +26,11 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 3
29
+ hash: 15
30
30
  segments:
31
31
  - 0
32
- version: "0"
32
+ - 2
33
+ version: "0.2"
33
34
  type: :runtime
34
35
  version_requirements: *id001
35
36
  - !ruby/object:Gem::Dependency
@@ -40,12 +41,11 @@ dependencies:
40
41
  requirements:
41
42
  - - ~>
42
43
  - !ruby/object:Gem::Version
43
- hash: 19
44
+ hash: 15
44
45
  segments:
45
46
  - 1
46
47
  - 0
47
- - 2
48
- version: 1.0.2
48
+ version: "1.0"
49
49
  type: :development
50
50
  version_requirements: *id002
51
51
  - !ruby/object:Gem::Dependency
@@ -56,12 +56,11 @@ dependencies:
56
56
  requirements:
57
57
  - - ~>
58
58
  - !ruby/object:Gem::Version
59
- hash: 15
59
+ hash: 3
60
60
  segments:
61
61
  - 2
62
62
  - 0
63
- - 0
64
- version: 2.0.0
63
+ version: "2.0"
65
64
  type: :development
66
65
  version_requirements: *id003
67
66
  - !ruby/object:Gem::Dependency
@@ -72,12 +71,11 @@ dependencies:
72
71
  requirements:
73
72
  - - ~>
74
73
  - !ruby/object:Gem::Version
75
- hash: 9
74
+ hash: 1
76
75
  segments:
77
76
  - 2
78
77
  - 1
79
- - 1
80
- version: 2.1.1
78
+ version: "2.1"
81
79
  type: :development
82
80
  version_requirements: *id004
83
81
  description: Guard::Test automatically run your tests and notify you of the result when a file is modified.
@@ -105,8 +103,10 @@ homepage: http://rubygems.org/gems/guard-test
105
103
  licenses: []
106
104
 
107
105
  post_install_message:
108
- rdoc_options: []
109
-
106
+ rdoc_options:
107
+ - --charset=UTF-8
108
+ - --main=README.rdoc
109
+ - --exclude='(lib|test|spec)|(Gem|Guard|Rake)file'
110
110
  require_paths:
111
111
  - lib
112
112
  required_ruby_version: !ruby/object:Gem::Requirement