ZenTest 3.7.2 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,54 +4,62 @@ class Autotest::Rails < Autotest
4
4
 
5
5
  def initialize # :nodoc:
6
6
  super
7
- @exceptions = /^\.\/(?:db|doc|log|public|script|tmp|vendor\/rails)/
8
7
 
9
- @test_mappings = {
10
- %r%^test/fixtures/(.*)s.yml% => proc { |_, m|
11
- ["test/unit/#{m[1]}_test.rb",
12
- "test/controllers/#{m[1]}_controller_test.rb",
13
- "test/views/#{m[1]}_view_test.rb",
14
- "test/functional/#{m[1]}_controller_test.rb"]
15
- },
16
- %r%^test/(unit|integration|controllers|views|functional)/.*rb$% => proc { |filename, _|
17
- filename
18
- },
19
- %r%^app/models/(.*)\.rb$% => proc { |_, m|
20
- ["test/unit/#{m[1]}_test.rb"]
21
- },
22
- %r%^app/helpers/application_helper.rb% => proc {
8
+ add_exception %r%^\./(?:db|doc|log|public|script|tmp|vendor)%
9
+
10
+ add_mapping %r%^test/fixtures/(.*)s.yml% do |_, m|
11
+ ["test/unit/#{m[1]}_test.rb",
12
+ "test/controllers/#{m[1]}_controller_test.rb",
13
+ "test/views/#{m[1]}_view_test.rb",
14
+ "test/functional/#{m[1]}_controller_test.rb"]
15
+ end
16
+
17
+ add_mapping %r%^test/(unit|integration|controllers|views|functional)/.*rb$% do |filename, _|
18
+ filename
19
+ end
20
+
21
+ add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
22
+ "test/unit/#{m[1]}_test.rb"
23
+ end
24
+
25
+ add_mapping %r%^app/helpers/application_helper.rb% do
26
+ files_matching %r%^test/(views|functional)/.*_test\.rb$%
27
+ end
28
+
29
+ add_mapping %r%^app/helpers/(.*)_helper.rb% do |_, m|
30
+ if m[1] == "application" then
23
31
  files_matching %r%^test/(views|functional)/.*_test\.rb$%
24
- },
25
- %r%^app/helpers/(.*)_helper.rb% => proc { |_, m|
26
- if m[1] == "application" then
27
- files_matching %r%^test/(views|functional)/.*_test\.rb$%
28
- else
29
- ["test/views/#{m[1]}_view_test.rb",
30
- "test/functional/#{m[1]}_controller_test.rb"]
31
- end
32
- },
33
- %r%^app/views/(.*)/% => proc { |_, m|
32
+ else
34
33
  ["test/views/#{m[1]}_view_test.rb",
35
34
  "test/functional/#{m[1]}_controller_test.rb"]
36
- },
37
- %r%^app/controllers/(.*)\.rb$% => proc { |_, m|
38
- if m[1] == "application" then
39
- files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
40
- else
41
- ["test/controllers/#{m[1]}_test.rb",
42
- "test/functional/#{m[1]}_test.rb"]
43
- end
44
- },
45
- %r%^app/views/layouts/% => proc {
46
- "test/views/layouts_view_test.rb"
47
- },
48
- %r%^config/routes.rb$% => proc { # FIX:
35
+ end
36
+ end
37
+
38
+ add_mapping %r%^app/views/(.*)/% do |_, m|
39
+ ["test/views/#{m[1]}_view_test.rb",
40
+ "test/functional/#{m[1]}_controller_test.rb"]
41
+ end
42
+
43
+ add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
44
+ if m[1] == "application" then
49
45
  files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
50
- },
51
- %r%^test/test_helper.rb|config/((boot|environment(s/test)?).rb|database.yml)% => proc {
52
- files_matching %r%^test/(unit|controllers|views|functional)/.*_test\.rb$%
53
- },
54
- }
46
+ else
47
+ ["test/controllers/#{m[1]}_test.rb",
48
+ "test/functional/#{m[1]}_test.rb"]
49
+ end
50
+ end
51
+
52
+ add_mapping %r%^app/views/layouts/% do
53
+ "test/views/layouts_view_test.rb"
54
+ end
55
+
56
+ add_mapping %r%^config/routes.rb$% do # FIX:
57
+ files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
58
+ end
59
+
60
+ add_mapping %r%^test/test_helper.rb|config/((boot|environment(s/test)?).rb|database.yml)% do
61
+ files_matching %r%^test/(unit|controllers|views|functional)/.*_test\.rb$%
62
+ end
55
63
  end
56
64
 
57
65
  # Given the string filename as the path, determine
data/lib/zentest.rb CHANGED
@@ -56,7 +56,7 @@ end
56
56
 
57
57
  class ZenTest
58
58
 
59
- VERSION = '3.7.2'
59
+ VERSION = '3.8.0'
60
60
 
61
61
  include ZenTestMapping
62
62
 
@@ -18,6 +18,8 @@ require 'autotest'
18
18
  # run_tests
19
19
 
20
20
  class Autotest
21
+ attr_reader :test_mappings, :exception_list
22
+
21
23
  def self.clear_hooks
22
24
  HOOKS.clear
23
25
  end
@@ -46,6 +48,45 @@ class TestAutotest < Test::Unit::TestCase
46
48
  @a.last_mtime = Time.at(2)
47
49
  end
48
50
 
51
+ def test_add_exception
52
+ current = util_exceptions
53
+ @a.add_exception 'blah'
54
+
55
+ actual = util_exceptions
56
+ expect = current + ["blah"]
57
+
58
+ assert_equal expect, actual
59
+ end
60
+
61
+ def test_add_mapping
62
+ current = util_mappings
63
+ @a.add_mapping(/blah/) do 42 end
64
+
65
+ actual = util_mappings
66
+ expect = current + [/blah/]
67
+
68
+ assert_equal expect, actual
69
+ end
70
+
71
+ def test_clear_exceptions
72
+ test_add_exception
73
+ @a.clear_exceptions
74
+
75
+ actual = util_exceptions
76
+ expect = []
77
+
78
+ assert_equal expect, actual
79
+ end
80
+
81
+ def test_clear_mapping
82
+ @a.clear_mappings
83
+
84
+ actual = util_mappings
85
+ expect = []
86
+
87
+ assert_equal expect, actual
88
+ end
89
+
49
90
  def test_consolidate_failures_experiment
50
91
  @a.files.clear
51
92
  @a.files[@impl] = Time.at(1)
@@ -72,14 +113,6 @@ class TestAutotest < Test::Unit::TestCase
72
113
  assert_equal expected, @a.output.string
73
114
  end
74
115
 
75
- def test_consolidate_failures_no_match
76
- result = @a.consolidate_failures([['test_blah1', @test_class], ['test_blah2', @test_class], ['test_blah1', 'TestUnknown']])
77
- expected = {@test => ['test_blah1', 'test_blah2']}
78
- assert_equal expected, result
79
- expected = "Unable to map class TestUnknown to a file\n"
80
- assert_equal expected, @a.output.string
81
- end
82
-
83
116
  def test_consolidate_failures_nested_classes
84
117
  @a.files.clear
85
118
  @a.files['lib/outer.rb'] = Time.at(5)
@@ -93,14 +126,32 @@ class TestAutotest < Test::Unit::TestCase
93
126
  assert_equal expected, @a.output.string
94
127
  end
95
128
 
129
+ def test_consolidate_failures_no_match
130
+ result = @a.consolidate_failures([['test_blah1', @test_class], ['test_blah2', @test_class], ['test_blah1', 'TestUnknown']])
131
+ expected = {@test => ['test_blah1', 'test_blah2']}
132
+ assert_equal expected, result
133
+ expected = "Unable to map class TestUnknown to a file\n"
134
+ assert_equal expected, @a.output.string
135
+ end
136
+
96
137
  def test_consolidate_failures_red
97
138
  result = @a.consolidate_failures([['test_blah1', @test_class], ['test_blah2', @test_class]])
98
139
  expected = {@test => ['test_blah1', 'test_blah2']}
99
140
  assert_equal expected, result
100
141
  end
101
142
 
102
- # TODO: lots of filename edgecases for find_files_to_test
143
+ def test_exceptions
144
+ @a.clear_exceptions
145
+ test_add_exception
146
+ assert_equal(/blah/, @a.exceptions)
147
+ end
148
+
149
+ def test_exceptions_nil
150
+ @a.clear_exceptions
151
+ assert_nil @a.exceptions
152
+ end
103
153
 
154
+ # TODO: lots of filename edgecases for find_files_to_test
104
155
  def test_find_files_to_test
105
156
  @a.last_mtime = Time.at(0)
106
157
  assert @a.find_files_to_test(@a.files)
@@ -261,10 +312,6 @@ test_error2(#{@test_class}):
261
312
  assert_equal expected, result
262
313
  end
263
314
 
264
- def util_path_to_classname(e,i)
265
- assert_equal e, @a.path_to_classname(i)
266
- end
267
-
268
315
  def test_path_to_classname
269
316
  # non-rails
270
317
  util_path_to_classname 'TestBlah', 'test/test_blah.rb'
@@ -272,6 +319,27 @@ test_error2(#{@test_class}):
272
319
  util_path_to_classname 'TestRuby2Ruby', 'test/test_ruby2ruby.rb'
273
320
  end
274
321
 
322
+ def test_remove_exception
323
+ test_add_exception
324
+ current = util_exceptions
325
+ @a.remove_exception 'blah'
326
+
327
+ actual = util_exceptions
328
+ expect = current - ["blah"]
329
+
330
+ assert_equal expect, actual
331
+ end
332
+
333
+ def test_remove_mapping
334
+ current = util_mappings
335
+ @a.remove_mapping(/^lib\/.*\.rb$/)
336
+
337
+ actual = util_mappings
338
+ expect = current - [/^lib\/.*\.rb$/]
339
+
340
+ assert_equal expect, actual
341
+ end
342
+
275
343
  def test_tests_for_file
276
344
  assert_equal [@test], @a.tests_for_file(@impl)
277
345
  assert_equal [@test], @a.tests_for_file(@test)
@@ -282,6 +350,10 @@ test_error2(#{@test_class}):
282
350
  assert_equal [], @a.tests_for_file('test_unknown.rb')
283
351
  end
284
352
 
353
+ def util_exceptions
354
+ @a.exception_list.sort_by { |r| r.to_s }
355
+ end
356
+
285
357
  def util_find_files_to_test(f, expected)
286
358
  t = @a.last_mtime + 1
287
359
  files = { f => t }
@@ -291,4 +363,12 @@ test_error2(#{@test_class}):
291
363
  assert_equal t, @a.files[f]
292
364
  assert_equal "", @a.output.string
293
365
  end
366
+
367
+ def util_mappings
368
+ @a.test_mappings.keys.sort_by { |x| x.to_s }
369
+ end
370
+
371
+ def util_path_to_classname(e,i)
372
+ assert_equal e, @a.path_to_classname(i)
373
+ end
294
374
  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.7.2
4
+ version: 3.8.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: 2008-01-09 00:00:00 -08:00
13
+ date: 2008-01-14 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -34,16 +34,18 @@ extensions: []
34
34
 
35
35
  extra_rdoc_files:
36
36
  - History.txt
37
- - LinuxJournalArticle.txt
38
37
  - Manifest.txt
39
38
  - README.txt
39
+ - articles/how_to_use_zentest.txt
40
40
  - example.txt
41
41
  files:
42
42
  - History.txt
43
- - LinuxJournalArticle.txt
44
43
  - Manifest.txt
45
44
  - README.txt
46
45
  - Rakefile
46
+ - articles/Article.css
47
+ - articles/getting_started_with_autotest.html
48
+ - articles/how_to_use_zentest.txt
47
49
  - bin/autotest
48
50
  - bin/multiruby
49
51
  - bin/rails_test_audit