guard-test 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
17
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
18
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
19
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = Guard::Test
2
2
 
3
- Guard::Test allows to automatically & intelligently launch tests when files are modified or created.
3
+ Test::Unit guard allows to automatically & intelligently launch tests when files are modified or created.
4
4
 
5
5
  == Compatibility
6
6
 
@@ -9,7 +9,7 @@ Guard::Test allows to automatically & intelligently launch tests when files are
9
9
 
10
10
  == Install
11
11
 
12
- Please be sure to have {guard}[http://github.com/guard/guard] installed before continue.
12
+ Please be sure to have {Guard}[https://github.com/guard/guard] installed before continue.
13
13
 
14
14
  Install the gem:
15
15
 
@@ -19,41 +19,40 @@ Add it to your Gemfile (inside test group):
19
19
 
20
20
  gem 'guard-test'
21
21
 
22
- Add guard definition to your Guardfile by running this command:
22
+ Add Guard definition to your Guardfile by running this command:
23
23
 
24
24
  guard init test
25
25
 
26
26
  == Usage
27
27
 
28
- Please read {guard usage doc}[http://github.com/guard/guard#readme].
28
+ Please read {Guard usage doc}[https://github.com/guard/guard#readme].
29
29
 
30
30
  == Guardfile
31
31
 
32
32
  Guard::Test can be adapted to many kind of projects.
33
- Please read {guard doc}[http://github.com/guard/guard#readme] for more info about Guardfile DSL.
34
33
 
35
34
  === Standard Ruby project
36
35
 
37
36
  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" }
37
+ watch(%r{lib/(.*)\.rb}) { |m| "test/#{m[1]}_test.rb" }
38
+ watch(%r{test/.*_test\.rb})
39
+ watch('test/test_helper.rb') { "test" }
41
40
  end
42
41
 
43
42
  === Ruby On Rails project
44
43
 
45
44
  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" }
45
+ watch(%r{app/models/(.*)\.rb}) { |m| "test/unit/#{m[1]}_test.rb" }
46
+ watch(%r{app/controllers/(.*)\.rb}) { |m| "test/functional/#{m[1]}_test.rb" }
47
+ watch(%r{app/views/.*\.rb}) { "test/integration" }
48
+ watch(%r{lib/(.*)\.rb}) { |m| "test/#{m[1]}_test.rb" }
49
+ watch(%r{test/.*_test.rb})
50
+ watch('app/controllers/application_controller.rb') { ["test/functional", "test/integration"] }
51
+ watch('test/test_helper.rb') { "test" }
55
52
  end
56
53
 
54
+ Please read {Guard doc}[https://github.com/guard/guard#readme] for more info about Guardfile DSL.
55
+
57
56
  == Options
58
57
 
59
58
  Guard::Test allows you to choose between two different runners (Guard::Test's runners are inherited from Test::Unit's console runner):
@@ -62,8 +61,8 @@ Guard::Test allows you to choose between two different runners (Guard::Test's ru
62
61
 
63
62
  Available options:
64
63
 
65
- :runner => 'fastfail' # default to 'default'
66
- :bundler => false # don't use "bundle exec"
64
+ :runner => 'fastfail' # default to 'default'
65
+ :bundler => false # don't use "bundle exec"
67
66
  :rvm => ['1.8.7', '1.9.2'] # directly run your specs on multiple ruby
68
67
 
69
68
  Set the desired options as follow method:
@@ -74,8 +73,8 @@ Set the desired options as follow method:
74
73
 
75
74
  == Development
76
75
 
77
- - Source hosted on GitHub: http://github.com/guard/guard-test
78
- - Report issues/Questions/Feature requests on GitHub Issues: http://github.com/guard/guard-test/issues
76
+ - Source hosted on GitHub: https://github.com/guard/guard-test
77
+ - Report issues/Questions/Feature requests on GitHub Issues: https://github.com/guard/guard-test/issues
79
78
 
80
79
  Pull requests are very welcome!
81
80
  Make sure your patches are well tested.
@@ -83,8 +82,8 @@ Please create a topic branch for every separate change you make.
83
82
 
84
83
  == Author
85
84
 
86
- {Rémy Coutable}[http://github.com/rymai]
85
+ {Rémy Coutable}[https://github.com/rymai]
87
86
 
88
- == Kudo
87
+ == Kudos
89
88
 
90
- Many thanks to {Thibaud Guillaume-Gentil}[http://github.com/thibaudgg] for creating the excellent Guard gem.
89
+ Many thanks to {Thibaud Guillaume-Gentil}[https://github.com/thibaudgg] for creating the excellent Guard gem.
data/lib/guard/test.rb CHANGED
@@ -3,28 +3,29 @@ require 'guard/guard'
3
3
 
4
4
  module Guard
5
5
  class Test < Guard
6
-
6
+
7
7
  autoload :Runner, 'guard/test/runner'
8
8
  autoload :Inspector, 'guard/test/inspector'
9
-
9
+
10
10
  def start
11
11
  Runner.set_test_unit_runner(options)
12
12
  UI.info "Guard::Test is guarding your tests!"
13
13
  end
14
-
14
+
15
15
  def run_all
16
16
  clean_and_run(["test"], :message => "Running all tests")
17
17
  end
18
-
18
+
19
19
  def run_on_change(paths)
20
20
  clean_and_run(paths)
21
21
  end
22
-
22
+
23
23
  private
24
-
25
- def clean_and_run(paths, options = {})
24
+
25
+ def clean_and_run(paths, options={})
26
26
  paths = Inspector.clean(paths)
27
27
  Runner.run(paths, options) unless paths.empty?
28
28
  end
29
+
29
30
  end
30
- end
31
+ end
@@ -1,62 +1,62 @@
1
1
  module Formatter
2
-
3
- def print_results(test_count, assertion_count, failure_count, error_count, duration, options = {})
2
+
3
+ def print_results(test_count, assertion_count, failure_count, error_count, duration, options={})
4
4
  puts_with_color(duration_text(duration, options)) if options[:with_duration]
5
5
  color = (failure_count > 0 ? "failure" : (error_count > 0 ? "error" : "pass"))
6
6
  puts_with_color(results_text(test_count, assertion_count, failure_count, error_count), color)
7
7
  end
8
-
8
+
9
9
  def notify_results(test_count, assertion_count, failure_count, error_count, duration)
10
10
  notify(
11
11
  results_text(test_count, assertion_count, failure_count, error_count) + duration_text(duration, :short => true),
12
12
  image(failure_count + error_count)
13
13
  )
14
14
  end
15
-
16
- def print_and_notify_results(test_count, assertion_count, failure_count, error_count, duration, options = {})
15
+
16
+ def print_and_notify_results(test_count, assertion_count, failure_count, error_count, duration, options={})
17
17
  print_results(test_count, assertion_count, failure_count, error_count, duration, options)
18
18
  notify_results(test_count, assertion_count, failure_count, error_count, duration)
19
19
  end
20
-
20
+
21
21
  def image(failure_count)
22
22
  failure_count > 0 ? :failed : :success
23
23
  end
24
-
24
+
25
25
  def notify(message, image)
26
26
  Guard::Notifier.notify(message, :title => "Test::Unit results", :image => image)
27
27
  end
28
-
29
- def print_with_color(something, color_name = "reset")
28
+
29
+ def print_with_color(something, color_name="reset")
30
30
  something = "%s%s%s" % [color_sequence(color_name), something, color_sequence("reset")]
31
31
  $stdout.write(something)
32
32
  $stdout.flush
33
33
  true
34
34
  end
35
-
36
- def puts_with_color(something, color_name = "reset")
35
+
36
+ def puts_with_color(something, color_name="reset")
37
37
  print_with_color(something, color_name)
38
38
  $stdout.puts
39
39
  end
40
-
40
+
41
41
  private
42
-
43
- def color_sequence(color_name = "reset")
42
+
43
+ def color_sequence(color_name="reset")
44
44
  "\e[0#{color_code(color_name)}m"
45
45
  end
46
-
47
- def color_code(name = "reset")
46
+
47
+ def color_code(name="reset")
48
48
  { "pass" => ";32", "failure" => ";31", "pending" => ";33", "error" => ";35", "reset" => "" }[name]
49
49
  end
50
-
50
+
51
51
  def results_text(test_count, assertion_count, failure_count, error_count)
52
52
  "#{test_count} tests, #{assertion_count} asserts, #{failure_count} fails, #{error_count} errors"
53
53
  end
54
-
55
- def duration_text(duration, options = {})
54
+
55
+ def duration_text(duration, options={})
56
56
  "\n\n#{"Finished " unless options[:short]}in #{round_float(duration)} seconds\n"
57
57
  end
58
-
59
- def round_float(float, decimals = 4)
58
+
59
+ def round_float(float, decimals=4)
60
60
  if Float.instance_method(:round).arity == 0 # Ruby 1.8
61
61
  factor = 10**decimals
62
62
  (float*factor).round / factor.to_f
@@ -64,5 +64,5 @@ private
64
64
  float.round(decimals)
65
65
  end
66
66
  end
67
-
68
- end
67
+
68
+ end
@@ -2,44 +2,44 @@ module Guard
2
2
  class Test
3
3
  module Inspector
4
4
  class << self
5
-
5
+
6
6
  def clean(paths)
7
7
  paths.uniq!
8
8
  paths.compact!
9
9
  clean_paths = paths.select { |p| test_file?(p) || test_folder?(p) }
10
-
10
+
11
11
  paths.each do |path|
12
12
  if File.directory?(path)
13
13
  clean_paths.delete(path)
14
14
  clean_paths = clean_paths + Dir.glob("#{path}/**/*_test.rb")
15
15
  end
16
16
  end
17
-
17
+
18
18
  clean_paths.uniq!
19
19
  clean_paths.compact!
20
20
  clear_test_files_list
21
21
  clean_paths.sort
22
22
  end
23
-
23
+
24
24
  private
25
-
25
+
26
26
  def test_folder?(path)
27
27
  path.match(/^\/?test/) && !path.match(/\..+$/)
28
28
  end
29
-
29
+
30
30
  def test_file?(path)
31
31
  test_files.include?(path)
32
32
  end
33
-
33
+
34
34
  def test_files
35
35
  @test_files ||= Dir.glob("test/**/*_test.rb")
36
36
  end
37
-
37
+
38
38
  def clear_test_files_list
39
39
  @test_files = nil
40
40
  end
41
-
41
+
42
42
  end
43
43
  end
44
44
  end
45
- end
45
+ end
@@ -3,39 +3,39 @@ module Guard
3
3
  module Runner
4
4
  class << self
5
5
  attr_reader :test_unit_runner
6
-
6
+
7
7
  AVAILABLE_TEST_UNIT_RUNNERS = %w[default fastfail]
8
-
9
- def set_test_unit_runner(options = {})
8
+
9
+ def set_test_unit_runner(options={})
10
10
  @test_unit_runner = AVAILABLE_TEST_UNIT_RUNNERS.include?(options[:runner]) ? options[:runner] : 'default'
11
11
  end
12
-
13
- def run(paths, options = {})
12
+
13
+ def run(paths, options={})
14
14
  message = "\n" + (options[:message] || "Running (#{@test_unit_runner} runner): #{paths.join(' ') }")
15
15
  UI.info(message, :reset => true)
16
16
  system(test_unit_command(paths, options))
17
17
  end
18
-
18
+
19
19
  private
20
-
21
- def test_unit_command(files, options = {})
20
+
21
+ def test_unit_command(files, options={})
22
22
  cmd_parts = []
23
- cmd_parts << "rvm #{options[:rvm].join(',')} exec" if options[:rvm].is_a?(Array)
23
+ cmd_parts << "rvm #{options[:rvm].join(',')} exec" if options[:rvm].respond_to?(:join)
24
24
  cmd_parts << "bundle exec" if bundler? && options[:bundler] != false
25
25
  cmd_parts << "ruby -rubygems"
26
26
  cmd_parts << "-r#{File.dirname(__FILE__)}/runners/#{@test_unit_runner}_test_unit_runner"
27
- cmd_parts << "-Itest"
27
+ cmd_parts << "-Ilib:test"
28
28
  cmd_parts << "-e \"%w[#{files.join(' ')}].each { |f| load f }\""
29
29
  cmd_parts << files.map { |f| "\"#{f}\"" }.join(' ')
30
30
  cmd_parts << "--runner=guard-#{@test_unit_runner}"
31
31
  cmd_parts.join(' ')
32
32
  end
33
-
33
+
34
34
  def bundler?
35
35
  @bundler ||= File.exist?("#{Dir.pwd}/Gemfile")
36
36
  end
37
-
37
+
38
38
  end
39
39
  end
40
40
  end
41
- end
41
+ end
@@ -6,52 +6,52 @@ require 'test/unit/ui/console/testrunner'
6
6
 
7
7
  # Thanks to Adam Sanderson for the really good starting point:
8
8
  # http://endofline.wordpress.com/2008/02/11/a-custom-testrunner-to-scratch-an-itch/
9
- #
9
+ #
10
10
  # This class inherits from Test::Unit' standard console TestRunner
11
11
  # I'm just overriding some callbacks methods to display some nicer results
12
12
  class DefaultGuardTestRunner < Test::Unit::UI::Console::TestRunner
13
13
  include Formatter
14
-
14
+
15
15
  def initialize(suite, options = {})
16
16
  super
17
17
  @use_color = true
18
18
  end
19
-
19
+
20
20
  protected
21
-
21
+
22
22
  # Test::Unit::UI::Console::TestRunner overrided methods
23
23
  def setup_mediator
24
24
  @mediator = Test::Unit::UI::TestRunnerMediator.new(@suite)
25
25
  end
26
-
26
+
27
27
  def started(result)
28
28
  @result = result
29
29
  end
30
-
30
+
31
31
  def test_started(name) # silence!
32
32
  end
33
-
33
+
34
34
  def add_fault(fault)
35
35
  @faults << fault
36
36
  print_with_color(fault.single_character_display, fault_color_name(fault))
37
37
  @already_outputted = true
38
38
  end
39
-
39
+
40
40
  def test_finished(name)
41
41
  print_with_color(".", "pass") unless @already_outputted
42
42
  @already_outputted = false
43
43
  end
44
-
44
+
45
45
  def finished(elapsed_time)
46
46
  nl
47
47
  super
48
48
  notify_results(@result.run_count, @result.assertion_count, @result.failure_count, @result.error_count, elapsed_time)
49
49
  end
50
-
50
+
51
51
  def fault_color_name(fault)
52
52
  fault.class.name.split(/::/).last.downcase
53
53
  end
54
-
54
+
55
55
  end
56
56
 
57
- Test::Unit::AutoRunner::RUNNERS["guard-default"] = Proc.new { |r| DefaultGuardTestRunner }
57
+ Test::Unit::AutoRunner::RUNNERS["guard-default"] = Proc.new { |r| DefaultGuardTestRunner }
@@ -5,20 +5,20 @@ require "#{File.dirname(__FILE__)}/default_test_unit_runner"
5
5
  # It inherits DefaultGuardTestRunner and redefines only 2 methods in order to display failures
6
6
  # as they happen (the default display them when all the tests are finished).
7
7
  class FastfailGuardTestUnitRunner < DefaultGuardTestRunner
8
-
8
+
9
9
  private
10
-
10
+
11
11
  def add_fault(fault)
12
12
  @faults << fault
13
13
  nl
14
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
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
23
23
 
24
- Test::Unit::AutoRunner::RUNNERS["guard-fastfail"] = Proc.new { |r| FastfailGuardTestUnitRunner }
24
+ Test::Unit::AutoRunner::RUNNERS["guard-fastfail"] = Proc.new { |r| FastfailGuardTestUnitRunner }
@@ -1,13 +1,11 @@
1
1
  guard 'test' do
2
- watch('^lib/(.*)\.rb') { |m| "test/lib/#{m[1]}_test.rb" }
3
- watch('^test/(.*)_test.rb')
4
- watch('^test/test_helper.rb') { "test" }
5
-
2
+ watch(%r{lib/(.*)\.rb}) { |m| "test/#{m[1]}_test.rb" }
3
+ watch(%r{test/.*_test\.rb})
4
+ watch('test/test_helper.rb') { "test" }
5
+
6
6
  # Rails example
7
- watch('^app/models/(.*)\.rb') { |m| "test/unit/#{m[1]}_test.rb" }
8
- watch('^app/controllers/(.*)\.rb') { |m| "test/functional/#{m[1]}_test.rb" }
9
- watch('^app/controllers/application_controller.rb') { "test/functional" }
10
- watch('^app/controllers/application_controller.rb') { "test/integration" }
11
- watch('^app/views/(.*)\.rb') { "test/integration" }
12
- watch('^test/factories.rb') { "test/unit" }
7
+ watch(%r{app/models/(.*)\.rb}) { |m| "test/unit/#{m[1]}_test.rb" }
8
+ watch(%r{app/controllers/(.*)\.rb}) { |m| "test/functional/#{m[1]}_test.rb" }
9
+ watch(%r{app/views/.*\.rb}) { "test/integration" }
10
+ watch('app/controllers/application_controller.rb') { ["test/functional", "test/integration"] }
13
11
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module TestVersion
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.6"
4
4
  end
5
- end
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: 19
5
- prerelease: false
4
+ hash: 23
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 6
10
+ version: 0.1.6
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-12-15 00:00:00 +01:00
18
+ date: 2011-01-24 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -24,14 +24,14 @@ dependencies:
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ">="
27
+ - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  hash: 19
30
30
  segments:
31
31
  - 0
32
- - 2
33
- - 2
34
- version: 0.2.2
32
+ - 3
33
+ - 0
34
+ version: 0.3.0
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -42,11 +42,12 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- hash: 1
45
+ hash: 15
46
46
  segments:
47
47
  - 2
48
48
  - 1
49
- version: "2.1"
49
+ - 2
50
+ version: 2.1.2
50
51
  type: :runtime
51
52
  version_requirements: *id002
52
53
  - !ruby/object:Gem::Dependency
@@ -89,12 +90,12 @@ dependencies:
89
90
  requirements:
90
91
  - - ~>
91
92
  - !ruby/object:Gem::Version
92
- hash: 3
93
+ hash: 31
93
94
  segments:
94
95
  - 2
95
- - 3
96
+ - 4
96
97
  - 0
97
- version: 2.3.0
98
+ version: 2.4.0
98
99
  type: :development
99
100
  version_requirements: *id005
100
101
  description: Guard::Test automatically run your tests and notify you of the result when a file is modified.
@@ -151,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
152
  requirements: []
152
153
 
153
154
  rubyforge_project: guard-test
154
- rubygems_version: 1.3.7
155
+ rubygems_version: 1.4.1
155
156
  signing_key:
156
157
  specification_version: 3
157
158
  summary: Guard gem for Test::Unit