ZenTest 3.11.1 → 4.0.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/lib/zentest.rb CHANGED
@@ -20,14 +20,10 @@ end
20
20
  $ZENTEST = true
21
21
  $TESTING = true
22
22
 
23
- require 'test/unit/testcase' # helps required modules
24
-
25
23
  class Module
26
-
27
24
  def zentest
28
25
  at_exit { ZenTest.autotest(self) }
29
26
  end
30
-
31
27
  end
32
28
 
33
29
  ##
@@ -56,7 +52,7 @@ end
56
52
 
57
53
  class ZenTest
58
54
 
59
- VERSION = '3.11.1'
55
+ VERSION = '4.0.0'
60
56
 
61
57
  include ZenTestMapping
62
58
 
@@ -120,7 +116,7 @@ class ZenTest
120
116
  end
121
117
 
122
118
  # Get the public instance, class and singleton methods for
123
- # class klass. If full is true, include the methods from
119
+ # class klass. If full is true, include the methods from
124
120
  # Kernel and other modules that get included. The methods
125
121
  # suite, new, pretty_print, pretty_print_cycle will not
126
122
  # be included in the resuting array.
@@ -207,7 +203,7 @@ class ZenTest
207
203
  return name
208
204
  end
209
205
 
210
- # Does all the work of finding a class by name,
206
+ # Does all the work of finding a class by name,
211
207
  # obtaining its methods and those of its superclass.
212
208
  # The full parameter determines if all the methods
213
209
  # including those of Object and mixed in modules
@@ -422,7 +418,7 @@ class ZenTest
422
418
  end # @klasses[klassname]
423
419
  end
424
420
 
425
- def test_to_normal(name, klassname=nil)
421
+ def test_to_normal(_name, klassname=nil)
426
422
  super do |name|
427
423
  if defined? @inherited_methods then
428
424
  known_methods = (@inherited_methods[klassname] || {}).keys.sort.reverse
@@ -449,7 +445,7 @@ class ZenTest
449
445
  meth.push indentunit*indent + "end"
450
446
  return meth
451
447
  end
452
-
448
+
453
449
  # Walk each known class and test that each method has
454
450
  # a test method
455
451
  # Then do it in the other direction...
@@ -2,8 +2,9 @@
2
2
 
3
3
  $TESTING = true
4
4
 
5
- require 'test/unit/testcase'
6
- require 'test/unit' if $0 == __FILE__
5
+ require 'rubygems'
6
+ require 'minitest/autorun'
7
+
7
8
  require 'stringio'
8
9
  require 'autotest'
9
10
 
@@ -25,7 +26,7 @@ class Autotest
25
26
  end
26
27
  end
27
28
 
28
- class TestAutotest < Test::Unit::TestCase
29
+ class TestAutotest < MiniTest::Unit::TestCase
29
30
 
30
31
  def deny test, msg=nil
31
32
  if msg then
@@ -296,7 +297,7 @@ test_error2(#{@test_class}):
296
297
  assert_equal empty, @a.files_to_test
297
298
 
298
299
  s3 = '
299
- /opt/bin/ruby -I.:lib:test -rtest/unit -e "%w[#{@test}].each { |f| require f }" | unit_diff -u
300
+ /opt/bin/ruby -I.:lib:test -rubygems -e "%w[test/unit #{@test}].each { |f| require f }" | unit_diff -u
300
301
  -e:1:in `require\': ./#{@test}:23: parse error, unexpected tIDENTIFIER, expecting \'}\' (SyntaxError)
301
302
  settings_fields.each {|e| assert_equal e, version.send e.intern}
302
303
  ^ from -e:1
@@ -357,7 +358,7 @@ test_error2(#{@test_class}):
357
358
  'test/test_fooby.rb' => [ 'test_something1', 'test_something2' ]
358
359
  }
359
360
 
360
- expected = [ "#{RUBY} -I.:lib:test -rtest/unit -e \"%w[#{@test}].each { |f| require f }\" | unit_diff -u",
361
+ expected = [ "#{RUBY} -I.:lib:test -rubygems -e \"%w[test/unit #{@test}].each { |f| require f }\" | unit_diff -u",
361
362
  "#{RUBY} -I.:lib:test test/test_fooby.rb -n \"/^(test_something1|test_something2)$/\" | unit_diff -u" ].join("; ")
362
363
 
363
364
  result = @a.make_test_cmd f
@@ -402,6 +403,16 @@ test_error2(#{@test_class}):
402
403
  assert_equal [], @a.test_files_for('test_unknown.rb')
403
404
  end
404
405
 
406
+ def test_testlib
407
+ assert_equal "test/unit", @a.testlib
408
+
409
+ @a.testlib = "MONKEY"
410
+ assert_equal "MONKEY", @a.testlib
411
+
412
+ f = { @test => [], "test/test_fooby.rb" => %w(first second) }
413
+ assert_match @a.testlib, @a.make_test_cmd(f)
414
+ end
415
+
405
416
  def util_exceptions
406
417
  @a.exception_list.sort_by { |r| r.to_s }
407
418
  end
@@ -0,0 +1,35 @@
1
+ require 'rubygems'
2
+ require 'minitest/autorun'
3
+ require 'focus'
4
+
5
+ class TestFocus < MiniTest::Unit::TestCase
6
+ def setup
7
+ @x = 1
8
+ end
9
+
10
+ def teardown
11
+ assert_equal 2, @x
12
+ end
13
+
14
+ def test_focus
15
+ @x += 1
16
+ end
17
+
18
+ def test_ignore1
19
+ flunk "ignore me!"
20
+ end
21
+
22
+ def test_ignore2
23
+ flunk "ignore me!"
24
+ end
25
+
26
+ def test_ignore3
27
+ flunk "ignore me!"
28
+ end
29
+
30
+ def test_focus2
31
+ @x += 1
32
+ end
33
+
34
+ focus :test_focus, :test_focus2
35
+ end
@@ -1,13 +1,15 @@
1
1
  #!/usr/local/bin/ruby -w
2
2
 
3
- require 'test/unit'
3
+ require 'rubygems'
4
+ require 'minitest/autorun'
5
+
4
6
  require 'stringio'
5
7
 
6
8
  $TESTING = true
7
9
 
8
10
  require 'unit_diff'
9
11
 
10
- class TestUnitDiff < Test::Unit::TestCase
12
+ class TestUnitDiff < MiniTest::Unit::TestCase
11
13
 
12
14
  def setup
13
15
  @diff = UnitDiff.new
data/test/test_zentest.rb CHANGED
@@ -1,14 +1,13 @@
1
1
  #!/usr/local/bin/ruby -w
2
2
 
3
- if defined? RUBY_ENGINE then
4
- warn "rubinius does not support features required by zentest. Skipping tests"
5
- return
6
- end
7
-
8
- require 'test/unit' unless defined? $ZENTEST and $ZENTEST
3
+ abort "rubinius does not support features required by zentest" if
4
+ defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
9
5
 
10
6
  $TESTING = true
11
7
 
8
+ require 'rubygems'
9
+ require 'minitest/autorun'
10
+
12
11
  # I do this so I can still run ZenTest against the tests and itself...
13
12
  require 'zentest' unless defined? $ZENTEST
14
13
 
@@ -140,12 +139,7 @@ end
140
139
 
141
140
  class TestTrueClass; end
142
141
 
143
- class TestZenTest < Test::Unit::TestCase
144
- unless defined? Mini then
145
- alias :refute_nil :assert_not_nil
146
- end
147
-
148
-
142
+ class TestZenTest < MiniTest::Unit::TestCase
149
143
  def setup
150
144
  @tester = ZenTest.new()
151
145
  end
@@ -1,7 +1,8 @@
1
- require 'test/unit' unless defined? $ZENTEST and $ZENTEST
2
-
3
1
  $TESTING = true
4
2
 
3
+ require 'rubygems'
4
+ require 'minitest/autorun'
5
+
5
6
  require 'zentest_mapping' unless defined? $ZENTEST
6
7
 
7
8
  class Dummy
@@ -9,7 +10,7 @@ class Dummy
9
10
  include ZenTestMapping
10
11
  end
11
12
 
12
- class TestZentestMapping < Test::Unit::TestCase
13
+ class TestZentestMapping < MiniTest::Unit::TestCase
13
14
  def setup
14
15
  @tester = Dummy.new
15
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ZenTest
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-01-20 00:00:00 -08:00
13
+ date: 2009-03-02 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -21,7 +21,7 @@ dependencies:
21
21
  requirements:
22
22
  - - ">="
23
23
  - !ruby/object:Gem::Version
24
- version: 1.8.2
24
+ version: 1.9.0
25
25
  version:
26
26
  description: "ZenTest provides 4 different tools and 1 library: zentest, unit_diff, autotest, multiruby, and Test::Rails. ZenTest scans your target and unit-test code and writes your missing code based on simple naming rules, enabling XP at a much quicker pace. ZenTest only works with Ruby and Test::Unit. unit_diff is a command-line filter to diff expected results from actual results and allow you to quickly see exactly what is wrong. autotest is a continous testing facility meant to be used during development. As soon as you save a file, autotest will run the corresponding dependent tests. multiruby runs anything you want on multiple versions of ruby. Great for compatibility checking! Use multiruby_setup to manage your installed versions. Test::Rails helps you build industrial-strength Rails code."
27
27
  email:
@@ -29,9 +29,9 @@ email:
29
29
  - drbrain@segment7.net
30
30
  executables:
31
31
  - autotest
32
+ - multigem
32
33
  - multiruby
33
34
  - multiruby_setup
34
- - rails_test_audit
35
35
  - unit_diff
36
36
  - zentest
37
37
  extensions: []
@@ -43,6 +43,7 @@ extra_rdoc_files:
43
43
  - articles/how_to_use_zentest.txt
44
44
  - example.txt
45
45
  files:
46
+ - .autotest
46
47
  - History.txt
47
48
  - Manifest.txt
48
49
  - README.txt
@@ -51,9 +52,9 @@ files:
51
52
  - articles/getting_started_with_autotest.html
52
53
  - articles/how_to_use_zentest.txt
53
54
  - bin/autotest
55
+ - bin/multigem
54
56
  - bin/multiruby
55
57
  - bin/multiruby_setup
56
- - bin/rails_test_audit
57
58
  - bin/unit_diff
58
59
  - bin/zentest
59
60
  - example.txt
@@ -82,35 +83,19 @@ files:
82
83
  - lib/autotest/rcov.rb
83
84
  - lib/autotest/redgreen.rb
84
85
  - lib/autotest/restart.rb
85
- - lib/autotest/screen.rb
86
86
  - lib/autotest/shame.rb
87
87
  - lib/autotest/snarl.rb
88
88
  - lib/autotest/timestamp.rb
89
+ - lib/focus.rb
89
90
  - lib/functional_test_matrix.rb
90
91
  - lib/multiruby.rb
91
- - lib/test/rails.rb
92
- - lib/test/rails/controller_test_case.rb
93
- - lib/test/rails/functional_test_case.rb
94
- - lib/test/rails/helper_test_case.rb
95
- - lib/test/rails/ivar_proxy.rb
96
- - lib/test/rails/pp_html_document.rb
97
- - lib/test/rails/rake_tasks.rb
98
- - lib/test/rails/render_tree.rb
99
- - lib/test/rails/test_case.rb
100
- - lib/test/rails/view_test_case.rb
101
- - lib/test/zentest_assertions.rb
102
92
  - lib/unit_diff.rb
103
93
  - lib/zentest.rb
104
94
  - lib/zentest_mapping.rb
105
95
  - test/test_autotest.rb
106
- - test/test_help.rb
107
- - test/test_rails_autotest.rb
108
- - test/test_rails_controller_test_case.rb
109
- - test/test_rails_helper_test_case.rb
110
- - test/test_rails_view_test_case.rb
96
+ - test/test_focus.rb
111
97
  - test/test_unit_diff.rb
112
98
  - test/test_zentest.rb
113
- - test/test_zentest_assertions.rb
114
99
  - test/test_zentest_mapping.rb
115
100
  has_rdoc: true
116
101
  homepage: http://www.zenspider.com/ZSS/Products/ZenTest/
@@ -141,12 +126,7 @@ specification_version: 2
141
126
  summary: "ZenTest provides 4 different tools and 1 library: zentest, unit_diff, autotest, multiruby, and Test::Rails"
142
127
  test_files:
143
128
  - test/test_autotest.rb
144
- - test/test_help.rb
145
- - test/test_rails_autotest.rb
146
- - test/test_rails_controller_test_case.rb
147
- - test/test_rails_helper_test_case.rb
148
- - test/test_rails_view_test_case.rb
129
+ - test/test_focus.rb
149
130
  - test/test_unit_diff.rb
150
131
  - test/test_zentest.rb
151
- - test/test_zentest_assertions.rb
152
132
  - test/test_zentest_mapping.rb
data/bin/rails_test_audit DELETED
@@ -1,80 +0,0 @@
1
- #!/usr/local/bin/ruby -w
2
-
3
- # TODO: Probably has dup code with ZenTest.
4
- # TODO: Map controller assert_assigns to view test ivar assignments.
5
- # TODO: Make this a rake task, rake test:audit.
6
-
7
- # test_cases[test_case][test][ivar] = value
8
- def build_test_cases(type)
9
- test_cases = Hash.new { |h,k|
10
- h[k] = Hash.new { |h,k|
11
- h[k] = Hash.new { |h,k|
12
- h[k] = {} } } }
13
-
14
- test_case = nil
15
- test = nil
16
-
17
- fixtures = Hash.new { |h,k| h[k] = [] }
18
-
19
- Dir["test/#{type}/*rb"].each do |test|
20
- File.open test do |fp|
21
- fp.each_line do |line|
22
- case line
23
- when /^class (.*)(View|Controller)Test </
24
- test_case = $1
25
- when /^\s+def (test_\S+)/
26
- test = $1
27
- when /^\s+controller\[(.+?)\] = (.*)$/,
28
- /^\s+assert_assigned (.*?), (.*)/
29
- ivar = $1
30
- value = $2
31
- test_cases[test_case][test][ivar] = value
32
- when /fixtures (.*)/ then
33
- fixtures[test_case].push(*$1.split(', '))
34
- end
35
- end
36
- end
37
- end
38
-
39
- return test_cases, fixtures
40
- end
41
-
42
- view_test_cases, view_fixtures = build_test_cases 'views'
43
- controller_test_cases, controller_fixtures = build_test_cases 'controller'
44
-
45
- out = []
46
-
47
- view_test_cases.sort_by { |tc,_| tc }.each do |test_case, tests|
48
- out << "require 'test/test_helper'"
49
- out << nil
50
- out << "class #{test_case}ControllerTest < Test::Rails::ControllerTestCase"
51
- out << nil
52
-
53
- fixtures = controller_fixtures[test_case] - view_fixtures[test_case]
54
-
55
- unless fixtures.empty? then
56
- fixtures.each do |fixture|
57
- out << " fixtures #{fixture}"
58
- end
59
- out << nil
60
- end
61
-
62
- tests.sort_by { |t,_| t }.each do |test, ivars|
63
- ivars = view_test_cases[test_case][test].keys -
64
- controller_test_cases[test_case][test].keys
65
-
66
- next if ivars.empty?
67
-
68
- out << " def #{test}"
69
- ivars.sort.each do |ivar|
70
- value = view_test_cases[test_case][test][ivar]
71
- out << " assert_assigned #{ivar}, #{value}"
72
- end
73
- out << " end"
74
- out << nil
75
- end
76
- out << "end"
77
- out << nil
78
- end
79
-
80
- puts out.join("\n")
@@ -1,73 +0,0 @@
1
- ##
2
- # Autotest::Screen is test result notify GNU Screen's statusline.
3
- #
4
- # === screenshots
5
- # * <img src="http://f.hatena.ne.jp/images/fotolife/s/secondlife/20061109/20061109015543.png" />
6
- # * <img src="http://f.hatena.ne.jp/images/fotolife/s/secondlife/20061109/20061109015522.png" />
7
- #
8
- # == SYNOPSIS
9
- # require 'autotest/screen'
10
- # # Autotest::Screen.statusline = '%H %`%-w%{=b bw}%n %t%{-}%+w (your statusline)'
11
- #
12
-
13
- class Autotest::Screen
14
- DEFAULT_STATUSLINE = '%H %`%-w%{=b bw}%n %t%{-}%+w'
15
- DEFAULT_SCREEN_CMD = 'screen'
16
-
17
- SCREEN_COLOR = {
18
- :black => 'dd',
19
- :green => 'gk',
20
- :red => 'rw',
21
- }
22
-
23
- def self.message(msg, color = :black)
24
- col = SCREEN_COLOR[color]
25
- msg = %Q[ %{=b #{col}} #{msg} %{-}]
26
- send_cmd(msg)
27
- end
28
-
29
- def self.clear
30
- send_cmd('')
31
- end
32
-
33
- def self.run_screen_session?
34
- str = `#{screen_cmd} -ls`
35
- str.match(/(\d+) Socket/) && ($1.to_i > 0)
36
- end
37
-
38
- def self.execute?
39
- !($TESTING || !run_screen_session?)
40
- end
41
-
42
- @statusline, @screen_cmd = nil
43
- def self.statusline; @statusline || DEFAULT_STATUSLINE.dup; end
44
- def self.statusline=(a); @statusline = a; end
45
- def self.screen_cmd; @screen_cmd || DEFAULT_SCREEN_CMD.dup; end
46
- def self.screen_cmd=(a); @screen_cmd = a; end
47
-
48
- def self.send_cmd(msg)
49
- cmd = %(#{screen_cmd} -X eval 'hardstatus alwayslastline "#{(statusline + msg).gsub('"', '\"')}"') #' stupid ruby-mode
50
- system cmd
51
- end
52
-
53
- Autotest.add_hook :run do |at|
54
- message 'Run Tests' if execute?
55
- end
56
-
57
- Autotest.add_hook :quit do |at|
58
- clear if execute?
59
- end
60
-
61
- Autotest.add_hook :ran_command do |at|
62
- if execute? then
63
- output = at.results.join
64
- failed = output.scan(/^\s+\d+\) (?:Failure|Error):\n(.*?)\((.*?)\)/)
65
- if failed.size == 0 then
66
- message "All Green", :green
67
- else
68
- f,e = failed.partition { |s| s =~ /Failure/ }
69
- message "Red F:#{f.size} E:#{e.size}", :red
70
- end
71
- end
72
- end
73
- end