ZenTest 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,46 @@
1
+ ##
2
+ # Extra assertions for Test::Unit
3
+
4
+ module Test::Unit::Assertions
5
+
6
+ ##
7
+ # Asserts that +boolean+ is not false or nil.
8
+
9
+ def deny(boolean, message = nil)
10
+ _wrap_assertion do
11
+ assert_block(build_message(message, "<?> is not false or nil.", boolean)) { not boolean }
12
+ end
13
+ end
14
+
15
+ ##
16
+ # Alias for assert_not_equal
17
+
18
+ alias deny_equal assert_not_equal
19
+
20
+ ##
21
+ # Asserts that +obj+ responds to #empty? and #empty? returns false.
22
+
23
+ def deny_empty(obj)
24
+ assert_respond_to obj, :empty?
25
+ assert_equal false, obj.empty?
26
+ end
27
+
28
+ ##
29
+ # Asserts that +obj+ responds to #include? and that obj includes +item+.
30
+
31
+ def assert_includes(obj, item, message = nil)
32
+ assert_respond_to obj, :include?
33
+ assert_equal true, obj.include?(item), message
34
+ end
35
+
36
+ ##
37
+ # Asserts that +obj+ responds to #include? and that obj does not include
38
+ # +item+.
39
+
40
+ def deny_includes(obj, item, message = nil)
41
+ assert_respond_to obj, :include?
42
+ assert_equal false, obj.include?(item), message
43
+ end
44
+
45
+ end
46
+
@@ -23,9 +23,55 @@ class Module
23
23
 
24
24
  end
25
25
 
26
+ ##
27
+ # ZenTest scans your target and unit-test code and writes your missing
28
+ # code based on simple naming rules, enabling XP at a much quicker
29
+ # pace. ZenTest only works with Ruby and Test::Unit.
30
+ #
31
+ # == RULES
32
+ #
33
+ # ZenTest uses the following rules to figure out what code should be
34
+ # generated:
35
+ #
36
+ # * Definition:
37
+ # * CUT = Class Under Test
38
+ # * TC = Test Class (for CUT)
39
+ # * TC's name is the same as CUT w/ "Test" prepended at every scope level.
40
+ # * Example: TestA::TestB vs A::B.
41
+ # * CUT method names are used in CT, with "test_" prependend and optional "_ext" extensions for differentiating test case edge boundaries.
42
+ # * Example:
43
+ # * A::B#blah
44
+ # * TestA::TestB#test_blah_normal
45
+ # * TestA::TestB#test_blah_missing_file
46
+ # * All naming conventions are bidirectional with the exception of test extensions.
47
+ #
48
+ # == METHOD MAPPING
49
+ #
50
+ # Method names are mapped bidirectionally in the following way:
51
+ #
52
+ # method test_method
53
+ # method? test_method_eh (too much exposure to Canadians :)
54
+ # method! test_method_bang
55
+ # method= test_method_equals
56
+ # [] test_index
57
+ # * test_times
58
+ # == test_equals2
59
+ # === test_equals3
60
+ #
61
+ # Further, any of the test methods should be able to have arbitrary
62
+ # extensions put on the name to distinguish edge cases:
63
+ #
64
+ # method test_method
65
+ # method test_method_simple
66
+ # method test_method_no_network
67
+ #
68
+ # To allow for unmapped test methods (ie, non-unit tests), name them:
69
+ #
70
+ # test_integration_.*
71
+
26
72
  class ZenTest
27
73
 
28
- VERSION = '3.1.0'
74
+ VERSION = '3.2.0'
29
75
 
30
76
  if $TESTING then
31
77
  attr_reader :missing_methods
@@ -51,7 +97,7 @@ class ZenTest
51
97
 
52
98
  unless file == $0 then
53
99
  begin
54
- require "#{file}"
100
+ require file
55
101
  rescue LoadError => err
56
102
  puts "Could not load #{file}: #{err}"
57
103
  end
File without changes
@@ -62,8 +62,8 @@ class TestAutotest < Test::Unit::TestCase
62
62
  ]
63
63
 
64
64
  expected = [
65
- ["'/^(test_a|test_b|test_c)/'", /one/],
66
- ["'/^(test_d)/'", /two/],
65
+ ["'/^(test_a|test_b|test_c)$/'", /one/],
66
+ ["'/^(test_d)$/'", /two/],
67
67
  ]
68
68
 
69
69
  assert_equal expected,
@@ -185,7 +185,7 @@ class TestAutotest < Test::Unit::TestCase
185
185
 
186
186
  assert_equal "# Waiting for changes", out.shift
187
187
  assert_equal "# Rerunning failures: #{@photo_test_file}", out.shift
188
- assert_equal "+ ruby -Ilib:test #{@photo_test_file} -n test_route | unit_diff -u", out.shift
188
+ assert_equal "+ #{@at.ruby} -Ilib:test #{@photo_test_file} -n test_route | unit_diff -u", out.shift
189
189
 
190
190
  assert_equal true, @at.backtick_responses.empty?
191
191
  end
@@ -205,6 +205,12 @@ class TestAutotest < Test::Unit::TestCase
205
205
  end
206
206
  end
207
207
 
208
+ def test_ruby
209
+ this_ruby = File.join(Config::CONFIG['bindir'],
210
+ Config::CONFIG['ruby_install_name'])
211
+ assert_equal this_ruby, @at.ruby
212
+ end
213
+
208
214
  def test_updated_eh
209
215
  Dir.chdir @normal_tests_dir do
210
216
  assert_equal true, @at.updated?(@photo_test_file), 'Not in @files'
@@ -230,8 +236,6 @@ class TestAutotest < Test::Unit::TestCase
230
236
  end
231
237
 
232
238
  def util_add_map(file, *tests)
233
- tests = [[],[]] if tests.empty?
234
-
235
239
  @file_map[file] = tests
236
240
  end
237
241
 
@@ -10,93 +10,186 @@ class TestRailsAutotest < TestAutotest
10
10
 
11
11
  @rails_tests_dir = 'test/data/rails'
12
12
 
13
- @rails_photo_file = 'app/models/photo.rb'
14
- @rails_unit_tests = [
15
- 'test/unit/flickr_photo_test.rb',
16
- 'test/unit/photo_test.rb',
17
- 'test/unit/route_test.rb',
13
+ @rails_unit_tests = ['test/unit/route_test.rb']
14
+
15
+ @rails_controller_tests = [
16
+ 'test/controllers/admin/themes_controller_test.rb',
17
+ 'test/controllers/articles_controller_test.rb',
18
+ 'test/controllers/dummy_controller_test.rb',
19
+ 'test/controllers/route_controller_test.rb',
20
+ ]
21
+
22
+ @rails_view_tests = [
23
+ 'test/views/admin/themes_view_test.rb',
24
+ 'test/views/articles_view_test.rb',
25
+ 'test/views/layouts_view_test.rb',
26
+ 'test/views/route_view_test.rb',
18
27
  ]
19
28
 
20
29
  @rails_functional_tests = [
21
30
  'test/functional/admin/themes_controller_test.rb',
31
+ 'test/functional/articles_controller_test.rb',
22
32
  'test/functional/dummy_controller_test.rb',
23
33
  'test/functional/route_controller_test.rb',
24
34
  ]
25
35
 
26
- @rails_all_tests = [@rails_unit_tests, @rails_functional_tests]
36
+ # These files aren't put in @file_map, so add them to it
37
+ @extra_files = [
38
+ 'test/controllers/admin/themes_controller_test.rb',
39
+ 'test/controllers/articles_controller_test.rb',
40
+ 'test/controllers/dummy_controller_test.rb',
41
+ 'test/views/admin/themes_view_test.rb',
42
+ 'test/views/articles_view_test.rb',
43
+ 'test/views/layouts_view_test.rb',
44
+ 'test/functional/articles_controller_test.rb',
45
+ 'test/functional/dummy_controller_test.rb',
46
+ ]
27
47
  end
28
48
 
29
- (instance_methods.sort - Object.instance_methods).each do |meth|
49
+ # Remove test_failed_test_files tests from RailsAutoTest because these
50
+ # tests are regular-mode dependent.
51
+ superclass.instance_methods.each do |meth|
30
52
  undef_method meth if meth =~ /^test_failed_test_files/
31
53
  end
32
54
 
33
55
  def test_map_file_names
56
+ # util_add_map(sourcefile, unit_tests, controller_tests,
57
+ # view_tests, functional_tsets)
58
+
34
59
  # controllers
35
- util_add_map("./app/controllers/admin/themes_controller.rb",
60
+ util_add_map("app/controllers/admin/themes_controller.rb",
61
+ [], ["test/controllers/admin/themes_controller_test.rb"],
36
62
  [], ["test/functional/admin/themes_controller_test.rb"])
37
- util_add_map("./app/controllers/application.rb",
63
+
64
+ util_add_map("app/controllers/application.rb",
65
+ [], ["test/controllers/dummy_controller_test.rb"],
38
66
  [], ["test/functional/dummy_controller_test.rb"])
39
- util_add_map("./app/controllers/route_controller.rb",
67
+
68
+ util_add_map("app/controllers/route_controller.rb",
69
+ [], ["test/controllers/route_controller_test.rb"],
40
70
  [], ["test/functional/route_controller_test.rb"])
41
- util_add_map("./app/controllers/notest_controller.rb")
71
+
72
+ util_add_map("app/controllers/notest_controller.rb")
42
73
 
43
74
  # helpers
44
- util_add_map("./app/helpers/application_helper.rb",
45
- [], ["test/functional/dummy_controller_test.rb",
46
- "test/functional/route_controller_test.rb"])
47
- util_add_map("./app/helpers/route_helper.rb",
48
- [], ["test/functional/route_controller_test.rb"])
75
+ util_add_map("app/helpers/application_helper.rb",
76
+ [], [], @rails_view_tests, @rails_functional_tests)
77
+
78
+ util_add_map("app/helpers/route_helper.rb",
79
+ [], [], ["test/views/route_view_test.rb"],
80
+ ["test/functional/route_controller_test.rb"])
49
81
 
50
82
  # model
51
- util_add_map("./app/models/route.rb",
52
- ["test/unit/route_test.rb"], [])
53
- util_add_map("./app/models/notest.rb")
83
+ util_add_map("app/models/route.rb",
84
+ ["test/unit/route_test.rb"], [], [], [])
85
+
86
+ util_add_map("app/models/notest.rb")
54
87
 
55
88
  # views
56
- util_add_map("./app/views/layouts/default.rhtml")
57
- util_add_map("./app/views/route/index.rhtml",
58
- [], ["test/functional/route_controller_test.rb"])
59
- util_add_map("./app/views/route/xml.rxml",
60
- [], ["test/functional/route_controller_test.rb"])
61
- util_add_map("./app/views/shared/notest.rhtml")
89
+ util_add_map("app/views/layouts/default.rhtml", [], [],
90
+ ["test/views/layouts_view_test.rb"], [])
91
+
92
+ util_add_map("app/views/route/index.rhtml",
93
+ [], [], ["test/views/route_view_test.rb"],
94
+ ["test/functional/route_controller_test.rb"])
95
+
96
+ util_add_map("app/views/route/xml.rxml",
97
+ [], [], ["test/views/route_view_test.rb"],
98
+ ["test/functional/route_controller_test.rb"])
99
+
100
+ util_add_map("app/views/shared/notest.rhtml")
101
+
102
+ util_add_map("app/views/articles/flag.rhtml",
103
+ [], [], ["test/views/articles_view_test.rb"],
104
+ ["test/functional/articles_controller_test.rb"])
62
105
 
63
106
  # tests
64
- util_add_map("./test/fixtures/routes.yml",
107
+ util_add_map("test/fixtures/routes.yml",
65
108
  ["test/unit/route_test.rb"],
109
+ ["test/controllers/route_controller_test.rb"],
110
+ ["test/views/route_view_test.rb"],
66
111
  ["test/functional/route_controller_test.rb"])
67
- util_add_map("./test/functional/admin/themes_controller_test.rb",
68
- [], ["test/functional/admin/themes_controller_test.rb"])
69
- util_add_map("./test/functional/route_controller_test.rb",
70
- [], ["test/functional/route_controller_test.rb"])
71
112
 
72
- util_add_map("./test/unit/photo_test.rb",
73
- ["test/unit/photo_test.rb"], [])
113
+ util_add_map("test/test_helper.rb",
114
+ @rails_unit_tests, @rails_controller_tests,
115
+ @rails_view_tests, @rails_functional_tests)
116
+
117
+ util_add_map("test/unit/route_test.rb",
118
+ ["test/unit/route_test.rb"], [], [], [])
119
+
120
+ util_add_map("test/controllers/route_controller_test.rb",
121
+ [], ["test/controllers/route_controller_test.rb"], [], [])
122
+
123
+ util_add_map("test/views/route_view_test.rb",
124
+ [], [], ["test/views/route_view_test.rb"], [])
74
125
 
75
- util_add_map("./test/test_helper.rb",
76
- @rails_unit_tests, @rails_functional_tests )
126
+ util_add_map("test/functional/route_controller_test.rb",
127
+ [], [], [], ["test/functional/route_controller_test.rb"])
128
+
129
+ util_add_map("test/functional/admin/themes_controller_test.rb",
130
+ [], [], [], ["test/functional/admin/themes_controller_test.rb"])
77
131
 
78
132
  # global conf thingies
79
- util_add_map("./config/boot.rb",
80
- @rails_unit_tests, @rails_functional_tests )
81
- util_add_map("./config/database.yml",
82
- @rails_unit_tests, @rails_functional_tests )
83
- util_add_map("./config/environment.rb",
84
- @rails_unit_tests, @rails_functional_tests )
85
- util_add_map("./config/environments/test.rb",
86
- @rails_unit_tests, @rails_functional_tests )
87
- util_add_map("./config/routes.rb",
88
- [], @rails_functional_tests)
133
+ util_add_map("config/boot.rb",
134
+ @rails_unit_tests, @rails_controller_tests,
135
+ @rails_view_tests, @rails_functional_tests)
136
+
137
+ util_add_map("config/database.yml",
138
+ @rails_unit_tests, @rails_controller_tests,
139
+ @rails_view_tests, @rails_functional_tests)
140
+
141
+ util_add_map("config/environment.rb",
142
+ @rails_unit_tests, @rails_controller_tests,
143
+ @rails_view_tests, @rails_functional_tests)
144
+
145
+ util_add_map("config/environments/test.rb",
146
+ @rails_unit_tests, @rails_controller_tests,
147
+ @rails_view_tests, @rails_functional_tests)
148
+
149
+ util_add_map("config/routes.rb",
150
+ [], @rails_controller_tests, @rails_view_tests,
151
+ @rails_functional_tests)
89
152
 
90
153
  # ignored crap
91
- util_add_map("./vendor/plugins/cartographer/lib/keys.rb")
92
- util_add_map("./Rakefile")
154
+ util_add_map("vendor/plugins/cartographer/lib/keys.rb")
93
155
 
94
- @rails_all_tests.flatten.each do |t|
95
- @at.files[t] = Time.at(0)
96
- end
156
+ util_add_map("Rakefile")
157
+
158
+ (@file_map.keys + @extra_files).each { |file| @at.files[file] = Time.at 0 }
97
159
 
98
160
  util_test_map_file_names @rails_tests_dir
99
161
  end
100
162
 
163
+ def test_updated_files_rails
164
+ expected = [
165
+ "app/controllers/admin/theme_controller.rb",
166
+ "app/controllers/route_controller.rb",
167
+ "app/models/flickr_photo.rb",
168
+ "app/models/route.rb",
169
+ "app/views/route/index.rhtml",
170
+ "config/environment.rb",
171
+ "config/routes.rb",
172
+ "test/controllers/route_controller_test.rb",
173
+ "test/fixtures/routes.yml",
174
+ "test/functional/admin/themes_controller_test.rb",
175
+ "test/functional/dummy_controller_test.rb",
176
+ "test/functional/route_controller_test.rb",
177
+ "test/unit/flickr_photo_test.rb",
178
+ "test/unit/photo_test.rb",
179
+ "test/unit/route_test.rb",
180
+ "test/views/route_view_test.rb",
181
+ ]
182
+
183
+ Dir.chdir @rails_tests_dir do
184
+ assert_equal expected, @at.updated_files.sort
185
+ end
186
+ end
187
+
188
+ def util_add_map(file, *tests)
189
+ tests = [[], [], [], []] if tests.empty?
190
+
191
+ super(file, *tests)
192
+ end
193
+
101
194
  end
102
195
 
metadata CHANGED
@@ -3,16 +3,20 @@ rubygems_version: 0.8.11.6
3
3
  specification_version: 1
4
4
  name: ZenTest
5
5
  version: !ruby/object:Gem::Version
6
- version: 3.1.0
7
- date: 2006-03-29 00:00:00 -08:00
8
- summary: == FEATURES/PROBLEMS
6
+ version: 3.2.0
7
+ date: 2006-04-10 00:00:00 -07:00
8
+ summary: |-
9
+ ZenTest can also be used to evaluate generated code and execute your
10
+ tests, allowing for very rapid development of both tests and
11
+ implementation.
9
12
  require_paths:
10
13
  - lib
11
14
  email: ryand-ruby@zenspider.com
12
15
  homepage: http://www.zenspider.com/ZSS/Products/ZenTest/
13
16
  rubyforge_project: zentest
14
17
  description: |-
15
- ZenTest provides 3 different tools: zentest, unit_diff, and autotest.
18
+ ZenTest provides 4 different tools and 1 library: zentest, unit_diff,
19
+ autotest, multiruby, and Test::Rails.
16
20
 
17
21
  ZenTest scans your target and unit-test code and writes your missing
18
22
  code based on simple naming rules, enabling XP at a much quicker
@@ -28,17 +32,16 @@ description: |-
28
32
  multiruby runs anything you want on multiple versions of ruby. Great
29
33
  for compatibility checking!
30
34
 
31
- There are two strategies intended for ZenTest: test conformance
32
- auditing and rapid XP.
35
+ Test::Rails helps you build industrial-strength Rails code.
36
+
37
+ == STRATEGERY
33
38
 
34
- For auditing, ZenTest provides an excellent means of finding methods
35
- that have slipped through the testing process. I've run it against my
36
- own software and found I missed a lot in a well tested
37
- package. Writing those tests found 4 bugs I had no idea existed.
39
+ There are two strategeries intended for ZenTest: test conformance
40
+ auditing and rapid XP.
38
41
  autorequire:
39
42
  default_executable:
40
43
  bindir: bin
41
- has_rdoc: false
44
+ has_rdoc: true
42
45
  required_ruby_version: !ruby/object:Gem::Version::Requirement
43
46
  requirements:
44
47
  - - ">"
@@ -60,6 +63,7 @@ files:
60
63
  - Rakefile
61
64
  - bin/autotest
62
65
  - bin/multiruby
66
+ - bin/rails_test_audit
63
67
  - bin/unit_diff
64
68
  - bin/zentest
65
69
  - example.txt
@@ -67,11 +71,20 @@ files:
67
71
  - example2.rb
68
72
  - lib/autotest.rb
69
73
  - lib/rails_autotest.rb
74
+ - lib/test/rails.rb
75
+ - lib/test/rails/controller_test_case.rb
76
+ - lib/test/rails/functional_test_case.rb
77
+ - lib/test/rails/ivar_proxy.rb
78
+ - lib/test/rails/rake_tasks.rb
79
+ - lib/test/rails/test_case.rb
80
+ - lib/test/rails/view_test_case.rb
81
+ - lib/test/zentest_assertions.rb
70
82
  - lib/unit_diff.rb
71
83
  - lib/zentest.rb
72
84
  - test/data/normal/lib/.#photo.rb
73
85
  - test/data/normal/lib/blah.rb
74
86
  - test/data/normal/lib/photo.rb
87
+ - test/data/normal/test/#test_photo.rb#
75
88
  - test/data/normal/test/test_camelcase.rb
76
89
  - test/data/normal/test/test_photo.rb
77
90
  - test/data/normal/test/test_route.rb
@@ -80,8 +93,10 @@ files:
80
93
  - test/data/rails/app/controllers/route_controller.rb
81
94
  - test/data/rails/app/models/flickr_photo.rb
82
95
  - test/data/rails/app/models/route.rb
96
+ - test/data/rails/app/views/route/index.rhtml
83
97
  - test/data/rails/config/environment.rb
84
98
  - test/data/rails/config/routes.rb
99
+ - test/data/rails/test/controllers/route_controller_test.rb
85
100
  - test/data/rails/test/fixtures/routes.yml
86
101
  - test/data/rails/test/functional/admin/themes_controller_test.rb
87
102
  - test/data/rails/test/functional/dummy_controller_test.rb
@@ -89,6 +104,7 @@ files:
89
104
  - test/data/rails/test/unit/flickr_photo_test.rb
90
105
  - test/data/rails/test/unit/photo_test.rb
91
106
  - test/data/rails/test/unit/route_test.rb
107
+ - test/data/rails/test/views/route_view_test.rb
92
108
  - test/test_autotest.rb
93
109
  - test/test_rails_autotest.rb
94
110
  - test/test_unit_diff.rb
@@ -100,10 +116,11 @@ rdoc_options: []
100
116
  extra_rdoc_files: []
101
117
 
102
118
  executables:
103
- - ZenTest
104
- - unit_diff
105
119
  - autotest
106
120
  - multiruby
121
+ - rails_test_audit
122
+ - unit_diff
123
+ - zentest
107
124
  extensions: []
108
125
 
109
126
  requirements: []