ZenTest 3.4.0 → 3.4.1

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,3 +1,18 @@
1
+ *** 3.4.1 / 2006-10-13
2
+
3
+ + 3 minor enhancements:
4
+ + FUNDAMENTALLY changed the way failures map back to tests. This REQUIRES users of autotest to ensure that their tests and impls map 1:1 at every scoping level. I'll blog more details.
5
+ + Hoe'd rakefile
6
+ + Added support for render :collection to RenderTree.
7
+ + 7 bug fixes:
8
+ + Fixed autotest tests for custom ruby names.
9
+ + Fixed some documentation errors in ControllerTestCase.
10
+ + Fixed setup in FunctionalTestCase.
11
+ + Allowed @assigns_ignored to contain either Symbols or Strings, bug 5233.
12
+ + Using Object.path2class to look up classes in helper test cases, bug 5493.
13
+ + Added assert_text_area, bug 5452.
14
+ + Renamed assert_select to assert_select_tag. Stupid rails. We were here first.
15
+
1
16
  *** 3.4.0 / 2006-09-12
2
17
 
3
18
  + 13 minor enhancements:
@@ -39,7 +39,10 @@ lib/test/zentest_assertions.rb
39
39
  lib/unit_diff.rb
40
40
  lib/zentest.rb
41
41
  test/test_autotest.rb
42
+ test/test_help.rb
42
43
  test/test_rails_autotest.rb
44
+ test/test_rails_helper_test_case.rb
45
+ test/test_rails_view_test_case.rb
43
46
  test/test_ruby_fork.rb
44
47
  test/test_unit_diff.rb
45
48
  test/test_zentest.rb
data/Rakefile CHANGED
@@ -1,60 +1,22 @@
1
1
  # -*- ruby -*-
2
2
 
3
- require 'rake'
4
- require 'rake/testtask'
5
- require 'rake/rdoctask'
6
- require 'rake/gempackagetask'
7
- require 'rake/contrib/sshpublisher'
8
- require 'rbconfig'
3
+ ENV["RUBY_FLAGS"]="-Ilib:bin:test" # FIX
9
4
 
5
+ require 'rubygems'
6
+ require 'hoe'
10
7
  require './lib/zentest.rb'
11
8
 
12
- $VERBOSE = nil
13
-
14
- spec = Gem::Specification.new do |s|
15
- s.name = 'ZenTest'
16
- s.version = ZenTest::VERSION
17
- s.authors = ['Ryan Davis', 'Eric Hodel']
18
- s.email = 'ryand-ruby@zenspider.com'
19
-
20
- s.files = IO.readlines("Manifest.txt").map {|f| f.chomp }
21
- s.require_path = 'lib'
22
-
23
- s.executables = s.files.grep(/^bin\//).map { |f| File.basename f }
24
-
9
+ Hoe.new("ZenTest", ZenTest::VERSION) do |p|
25
10
  paragraphs = File.read("README.txt").split(/\n\n+/)
26
- s.instance_variable_set "@description", paragraphs[3..10].join("\n\n")
27
- s.instance_variable_set "@summary", paragraphs[12]
28
11
 
29
- s.homepage = "http://www.zenspider.com/ZSS/Products/ZenTest/"
30
- s.rubyforge_project = "zentest"
31
- s.has_rdoc = true
12
+ p.author = ['Ryan Davis', 'Eric Hodel']
32
13
 
33
- if $DEBUG then
34
- puts "#{s.name} #{s.version}"
35
- puts
36
- puts s.executables.sort.inspect
37
- puts
38
- puts "** summary:"
39
- puts s.summary
40
- puts
41
- puts "** description:"
42
- puts s.description
43
- end
44
- end
14
+ changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
15
+ summary, *description = p.paragraphs_of("README.txt", 3, 3..8)
45
16
 
46
- desc 'Build Gem'
47
- Rake::GemPackageTask.new spec do |pkg|
48
- pkg.need_tar = true
49
- end
50
-
51
- desc 'Run tests'
52
- task :default => :test
53
-
54
- desc 'Run tests'
55
- Rake::TestTask.new :test do |t|
56
- t.libs << 'test'
57
- t.verbose = true
17
+ p.changes = changes
18
+ p.summary = summary
19
+ p.description = description.join("\n\n")
58
20
  end
59
21
 
60
22
  desc 'Update Manifest.txt'
@@ -62,73 +24,10 @@ task :update_manifest => :clean do
62
24
  sh "p4 open Manifest.txt; find . -type f | sed -e 's%./%%' | sort > Manifest.txt"
63
25
  end
64
26
 
65
- desc 'Generate RDoc'
66
- Rake::RDocTask.new :rdoc do |rd|
67
- rd.rdoc_dir = 'doc'
68
- rd.rdoc_files.add 'lib', 'README.txt', 'History.txt', 'LinuxJournalArticle.txt'
69
- rd.main = 'README.txt'
70
- rd.options << '-d' if `which dot` =~ /\/dot/ unless RUBY_PLATFORM =~ /win32/
71
- rd.options << '-t ZenTest RDoc'
72
- end
73
-
74
- desc 'Upload RDoc to RubyForge'
75
- task :upload => :rdoc do
76
-
77
- user = "#{ENV['USER']}@rubyforge.org"
78
- project = '/var/www/gforge-projects/zentest'
79
- local_dir = 'doc'
80
- pub = Rake::SshDirPublisher.new user, project, local_dir
81
- pub.upload
82
- end
83
-
84
- $prefix = ENV['PREFIX'] || Config::CONFIG['prefix']
85
- $bin = File.join($prefix, 'bin')
86
- $lib = Config::CONFIG['sitelibdir']
87
- $bins = spec.executables
88
- $libs = spec.files.grep(/^lib\//).map { |f| f.sub(/^lib\//, '') }.sort
89
-
90
27
  task :autotest do
91
28
  ruby "-Ilib ./bin/autotest"
92
29
  end
93
30
 
94
- task :install do
95
- $bins.each do |f|
96
- install File.join("bin", f), $bin, :mode => 0555
97
- end
98
-
99
- $libs.each do |f|
100
- dir = File.join($lib, File.dirname(f))
101
- mkdir_p dir unless test ?d, dir
102
- install File.join("lib", f), dir, :mode => 0444
103
- end
104
- end
105
-
106
- task :uninstall do
107
- # add old versions
108
- $bins << "ZenTest"
109
- $libs << "ZenTest.rb"
110
-
111
- $bins.each do |f|
112
- rm_f File.join($bin, f)
113
- end
114
-
115
- $libs.each do |f|
116
- rm_f File.join($lib, f)
117
- end
118
-
119
- rm_rf File.join($lib, "test")
120
- end
121
-
122
- desc 'Clean up'
123
- task :clean => [ :clobber_rdoc, :clobber_package ] do
124
- rm_f Dir["**/*~"]
125
- end
126
-
127
- task :help do
128
- Rake.application.options.show_task_pattern = //
129
- Rake.application.display_tasks_and_comments
130
- end
131
-
132
31
  task :sort do
133
32
  begin
134
33
  sh 'for f in lib/*.rb; do echo $f; grep "^ *def " $f | grep -v sort=skip > x; sort x > y; echo $f; echo; diff x y; done'
@@ -137,21 +137,24 @@ class Autotest
137
137
  @files_to_test.empty?
138
138
  end
139
139
 
140
+ def path_to_classname(s)
141
+ sep = File::SEPARATOR
142
+ f = s.sub(/^test#{sep}/, '').sub(/\.rb$/, '').split(sep)
143
+ f = f.map { |path| path.split(/_/).map { |seg| seg.capitalize }.join }
144
+ f = f.map { |path| path =~ /^Test/ ? path : "Test#{path}" }
145
+ f.join('::')
146
+ end
147
+
140
148
  def consolidate_failures(failed)
141
149
  filters = Hash.new { |h,k| h[k] = [] }
142
150
 
151
+ class_map = Hash[*@files.keys.grep(/^test/).map { |f| [path_to_classname(f), f] }.flatten]
152
+
143
153
  failed.each do |method, klass|
144
- klass = klass.split(/::/).last
145
- failed_file_name = klass.gsub(/(.)([A-Z])/, '\1_?\2')
146
- failed_files = @files.keys.grep(/#{failed_file_name}/i)
147
- case failed_files.size
148
- when 0 then
149
- @output.puts "Unable to map class #{klass} to a file" # FIX for testing
150
- when 1 then
151
- filters[failed_files.last] << method
154
+ if class_map.has_key? klass then
155
+ filters[class_map[klass]] << method
152
156
  else
153
- @output.puts "multiple files matched class #{klass} #{failed_files.inspect}."
154
- # nothing yet
157
+ @output.puts "Unable to map class #{klass} to a file"
155
158
  end
156
159
  end
157
160
 
@@ -48,5 +48,13 @@ class RailsAutotest < Autotest
48
48
  []
49
49
  end.uniq.select { |f| @files.has_key? f }
50
50
  end
51
+
52
+ def path_to_classname(s)
53
+ sep = File::SEPARATOR
54
+ f = s.sub(/^test#{sep}((unit|functional|integration|views|controllers|helpers)#{sep})?/, '').sub(/\.rb$/, '').split(sep)
55
+ f = f.map { |path| path.split(/_/).map { |seg| seg.capitalize }.join }
56
+ f = f.map { |path| path =~ /Test$/ ? path : "#{path}Test" }
57
+ f.join('::')
58
+ end
51
59
  end
52
60
 
@@ -33,14 +33,18 @@
33
33
  # fixtures :users, :routes, :points, :photos
34
34
  #
35
35
  # def test_delete
36
+ # # Store current count
37
+ # count = Route.count
36
38
  # # Set up our environment
37
39
  # session[:username] = users(:herbert).username
38
40
  #
39
- # # perform the delet action
41
+ # # perform the delete action
40
42
  # get :delete, :id => routes(:work).id
41
43
  #
42
44
  # # Assert we got a 200
43
45
  # assert_response :success
46
+ # # Assert controller deleted route
47
+ # assert_equal count-1, Route.count
44
48
  # # Ensure that @action_title is set properly
45
49
  # assert_assigned :action_title, "Deleting \"#{routes(:work).name}\""
46
50
  # # Ensure that @route is set properly
@@ -320,13 +324,11 @@ class Test::Rails::ControllerTestCase < Test::Rails::FunctionalTestCase
320
324
  all_assigns = assigns.keys.sort
321
325
 
322
326
  assigns_ignored = DEFAULT_ASSIGNS | @assigns_ignored
327
+ assigns_ignored = assigns_ignored.map { |a| a.to_s }
323
328
 
324
329
  assigns_created = all_assigns - assigns_ignored
325
330
  assigns_asserted = @assigns_asserted - assigns_ignored
326
331
 
327
- assigns_created = assigns_created
328
- assigns_asserted = assigns_asserted
329
-
330
332
  assigns_missing = assigns_created - assigns_asserted
331
333
 
332
334
  return if assigns_missing.empty?
@@ -18,6 +18,7 @@ class Test::Rails::FunctionalTestCase < Test::Rails::TestCase
18
18
 
19
19
  def setup
20
20
  return if self.class.name =~ /TestCase$/
21
+ super
21
22
 
22
23
  @controller_class = Object.path2class @controller_class_name
23
24
  raise "Can't determine controller class for #{self.class}" if @controller_class.nil?
@@ -40,7 +40,7 @@ class Test::Rails::HelperTestCase < Test::Rails::FunctionalTestCase
40
40
  def self.inherited(helper_testcase)
41
41
  super
42
42
  helper_name = helper_testcase.name.sub 'Test', ''
43
- helper_module = Object.const_get helper_name
43
+ helper_module = Object.path2class helper_name
44
44
  helper_testcase.send :include, helper_module
45
45
  rescue NameError
46
46
  raise "Unable to find helper #{helper_name}"
@@ -69,11 +69,15 @@ class ActionView::Base
69
69
  p args.first
70
70
  when Hash then
71
71
  hash = args.first
72
- found = hash.keys & RENDERS
73
- if found.length == 1 then
74
- puts "%p => %p" % [found.first, hash[found.first]]
72
+ if hash.include? :collection and hash.include? :partial then
73
+ puts "%p => %p" % [:collection, hash[:partial]]
75
74
  else
76
- raise "Dunno: %p" % [hash]
75
+ found = hash.keys & RENDERS
76
+ if found.length == 1 then
77
+ puts "%p => %p" % [found.first, hash[found.first]]
78
+ else
79
+ raise "Dunno: %p" % [hash]
80
+ end
77
81
  end
78
82
  else
79
83
  raise "Dunno: %p" % [args]
@@ -332,10 +332,10 @@ class Test::Rails::ViewTestCase < Test::Rails::FunctionalTestCase
332
332
  # <%= collection_select :game, :location_id, @locations, :id, :name %>
333
333
  #
334
334
  # test:
335
- # assert_select '/games/save', :game, :location_id,
336
- # 'Ballet' => 1, 'Guaymas' => 2
335
+ # assert_select_tag '/games/save', :game, :location_id,
336
+ # 'Ballet' => 1, 'Guaymas' => 2
337
337
 
338
- def assert_select(form_action, model, column, options)
338
+ def assert_select_tag(form_action, model, column, options)
339
339
  assert_kind_of Hash, options, "options needs to be a Hash"
340
340
  deny options.empty?, "options must not be empty"
341
341
  options.each do |option_name, option_id|
@@ -375,7 +375,7 @@ class Test::Rails::ViewTestCase < Test::Rails::FunctionalTestCase
375
375
  #
376
376
  # view:
377
377
  # <%= start_form_tag :action => 'save' %>
378
- # <table>
378
+ # [...]
379
379
  #
380
380
  # test:
381
381
  # assert_tag_in_form '/route/save', :tag => 'table'
@@ -385,6 +385,33 @@ class Test::Rails::ViewTestCase < Test::Rails::FunctionalTestCase
385
385
  :descendant => options
386
386
  end
387
387
 
388
+ ##
389
+ # Asserts that a form with +form_action+ has a textarea with name +name+ and
390
+ # optionally +value?.
391
+ #
392
+ # view:
393
+ # <%= text_area 'post', 'body' %>
394
+ #
395
+ # test:
396
+ # assert_text_area '/post/save', 'post[body]'
397
+ #
398
+ # view:
399
+ # <textarea id="post_body" name="post[body]">
400
+ # <%= @post.body %>
401
+ # </textarea>
402
+ #
403
+ # test:
404
+ # assert_text_area '/post/save', 'post[body]', posts(:post).body
405
+
406
+ def assert_text_area(form_action, name, value = nil)
407
+ attribs = {
408
+ :tag => 'textarea',
409
+ :attributes => { :name => name },
410
+ }
411
+ attribs[:content] = value if value
412
+ assert_tag_in_form form_action, attribs
413
+ end
414
+
388
415
  ##
389
416
  # Creates a new Paginator that uses the current controller. +item_count+,
390
417
  # +items_per_page+ and +page_number+ are passed straight through.
@@ -83,3 +83,11 @@ module Test::Unit::Assertions
83
83
 
84
84
  end
85
85
 
86
+ class Object # :nodoc:
87
+ unless respond_to? :path2class then
88
+ def path2class(path) # :nodoc:
89
+ path.split('::').inject(Object) { |k,n| k.const_get n }
90
+ end
91
+ end
92
+ end
93
+
@@ -75,7 +75,7 @@ end
75
75
 
76
76
  class ZenTest
77
77
 
78
- VERSION = '3.4.0'
78
+ VERSION = '3.4.1'
79
79
 
80
80
  if $TESTING then
81
81
  attr_reader :missing_methods
@@ -25,13 +25,16 @@ end
25
25
 
26
26
  class TestAutotest < Test::Unit::TestCase
27
27
 
28
- WINDOZE = /win32/ =~ RUBY_PLATFORM unless defined? WINDOZE
29
- RUBY = (WINDOZE ? 'c:\ruby\bin\ruby' : '/usr/local/bin/ruby') unless defined? RUBY
28
+ RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) unless defined? RUBY
30
29
 
31
30
  def setup
32
31
  @test_class = 'TestBlah'
33
32
  @test = 'test/test_blah.rb'
34
33
  @impl = 'lib/blah.rb'
34
+ @rails = self.class.name =~ /Rails/
35
+ @inner_test = 'test/outer/test_inner.rb'
36
+ @outer_test = 'test/test_outer.rb'
37
+ @inner_test_class = "TestOuter::TestInner"
35
38
 
36
39
  @a = Object.const_get(self.class.name[4..-1]).new
37
40
  @a.output = StringIO.new
@@ -43,12 +46,12 @@ class TestAutotest < Test::Unit::TestCase
43
46
 
44
47
  def test_consolidate_failures_experiment
45
48
  @a.files.clear
46
- @a.files['lib/autotest.rb'] = Time.at(1)
47
- @a.files['test/test_autotest.rb'] = Time.at(2)
49
+ @a.files[@impl] = Time.at(1)
50
+ @a.files[@test] = Time.at(2)
48
51
 
49
- input = [['test_fail1', 'TestAutotest'], ['test_fail2', 'TestAutotest'], ['test_error1', 'TestAutotest'], ['test_error2', 'TestAutotest']]
52
+ input = [['test_fail1', @test_class], ['test_fail2', @test_class], ['test_error1', @test_class], ['test_error2', @test_class]]
50
53
  result = @a.consolidate_failures input
51
- expected = { 'test/test_autotest.rb' => %w( test_fail1 test_fail2 test_error1 test_error2 ) }
54
+ expected = { @test => %w( test_fail1 test_fail2 test_error1 test_error2 ) }
52
55
  assert_equal expected, result
53
56
  end
54
57
 
@@ -58,12 +61,13 @@ class TestAutotest < Test::Unit::TestCase
58
61
  assert_equal expected, result
59
62
  end
60
63
 
61
- def test_consolidate_failures_multiple_matches
62
- @a.files['test/test_blah_again.rb'] = Time.at(42)
64
+ def test_consolidate_failures_multiple_possibilities
65
+ f = @rails ? 'test/other_blah_test.rb' : 'test/test_blah_other.rb'
66
+ @a.files[f] = Time.at(42)
63
67
  result = @a.consolidate_failures([['test_unmatched', @test_class]])
64
- expected = {}
68
+ expected = { @test => ['test_unmatched']}
65
69
  assert_equal expected, result
66
- expected = "multiple files matched class TestBlah [\"test/test_blah.rb\", \"test/test_blah_again.rb\"].\n"
70
+ expected = ""
67
71
  assert_equal expected, @a.output.string
68
72
  end
69
73
 
@@ -77,12 +81,12 @@ class TestAutotest < Test::Unit::TestCase
77
81
 
78
82
  def test_consolidate_failures_nested_classes
79
83
  @a.files.clear
80
- @a.files['lib/outer/inner.rb'] = Time.at(5)
81
- @a.files['test/outer/test_inner.rb'] = Time.at(5)
82
84
  @a.files['lib/outer.rb'] = Time.at(5)
83
- @a.files['test/test_outer.rb'] = Time.at(5)
84
- result = @a.consolidate_failures([['test_blah1', "TestOuter::TestInner"]])
85
- expected = {'test/outer/test_inner.rb' => ['test_blah1']}
85
+ @a.files['lib/outer/inner.rb'] = Time.at(5)
86
+ @a.files[@inner_test] = Time.at(5)
87
+ @a.files[@outer_test] = Time.at(5)
88
+ result = @a.consolidate_failures([['test_blah1', @inner_test_class]])
89
+ expected = { @inner_test => ['test_blah1'] }
86
90
  assert_equal expected, result
87
91
  expected = ""
88
92
  assert_equal expected, @a.output.string
@@ -144,8 +148,8 @@ class TestAutotest < Test::Unit::TestCase
144
148
  def test_handle_results
145
149
  @a.files_to_test.clear
146
150
  @a.files.clear
147
- @a.files['lib/autotest.rb'] = Time.at(1)
148
- @a.files['test/test_autotest.rb'] = Time.at(2)
151
+ @a.files[@impl] = Time.at(1)
152
+ @a.files[@test] = Time.at(2)
149
153
  empty = {}
150
154
  assert_equal empty, @a.files_to_test, "must start empty"
151
155
 
@@ -162,17 +166,17 @@ Finished in 0.001655 seconds.
162
166
 
163
167
  s2 = "
164
168
  1) Failure:
165
- test_fail1(TestAutotest) [./test/test_autotest.rb:59]:
169
+ test_fail1(#{@test_class}) [#{@test}:59]:
166
170
  2) Failure:
167
- test_fail2(TestAutotest) [./test/test_autotest.rb:59]:
171
+ test_fail2(#{@test_class}) [#{@test}:60]:
168
172
  3) Error:
169
- test_error1(TestAutotest):
173
+ test_error1(#{@test_class}):
170
174
  3) Error:
171
- test_error2(TestAutotest):
175
+ test_error2(#{@test_class}):
172
176
  "
173
177
 
174
178
  @a.handle_results(s2)
175
- expected = { "test/test_autotest.rb" => %w( test_fail1 test_fail2 test_error1 test_error2 ) }
179
+ expected = { @test => %w( test_fail1 test_fail2 test_error1 test_error2 ) }
176
180
  assert_equal expected, @a.files_to_test
177
181
 
178
182
  @a.handle_results(s1)
@@ -236,22 +240,24 @@ test_error2(TestAutotest):
236
240
  assert_equal expected, result
237
241
  end
238
242
 
243
+ def util_path_to_classname(e,i)
244
+ assert_equal e, @a.path_to_classname(i)
245
+ end
246
+
247
+ def test_path_to_classname
248
+ # non-rails
249
+ util_path_to_classname 'TestBlah', 'test/test_blah.rb'
250
+ util_path_to_classname 'TestOuter::TestInner', 'test/outer/test_inner.rb'
251
+ end
252
+
239
253
  def test_tests_for_file
240
254
  assert_equal [@test], @a.tests_for_file(@impl)
241
255
  assert_equal [@test], @a.tests_for_file(@test)
242
256
 
243
257
  assert_equal ['test/test_unknown.rb'], @a.tests_for_file('test/test_unknown.rb')
244
- # assert_equal [], @a.tests_for_file('test/test_unknown.rb')
245
258
  assert_equal [], @a.tests_for_file('lib/unknown.rb')
246
259
  assert_equal [], @a.tests_for_file('unknown.rb')
247
260
  assert_equal [], @a.tests_for_file('test_unknown.rb')
248
-
249
- # @a.files.clear
250
- # @a.files["blah.rb"] = Time.at(1)
251
- # @a.files["test_blah.rb"] = Time.at(2)
252
- # @a.last_mtime = Time.at(2)
253
- # assert_equal ["test_blah.rb"], @a.tests_for_file("test_blah.rb")
254
- # assert_equal ["test_blah.rb"], @a.tests_for_file("blah.rb")
255
261
  end
256
262
 
257
263
  def util_find_files_to_test(f, expected)
@@ -0,0 +1,12 @@
1
+ class ApplicationController; end
2
+
3
+ module ActionView; end
4
+ module ActionView::Helpers; end
5
+ module ActionView::Helpers::ActiveRecordHelper; end
6
+ module ActionView::Helpers::TagHelper; end
7
+ module ActionView::Helpers::FormTagHelper; end
8
+ module ActionView::Helpers::FormOptionsHelper; end
9
+ module ActionView::Helpers::FormHelper; end
10
+ module ActionView::Helpers::UrlHelper; end
11
+ module ActionView::Helpers::AssetTagHelper; end
12
+
@@ -10,6 +10,9 @@ class TestRailsAutotest < TestAutotest
10
10
  @test_class = 'RouteTest'
11
11
  @test = 'test/unit/route_test.rb'
12
12
  @impl = 'app/models/route.rb'
13
+ @inner_test = 'test/outer/inner_test.rb'
14
+ @outer_test = 'test/outer_test.rb'
15
+ @inner_test_class = "OuterTest::InnerTest"
13
16
 
14
17
  @rails_unit_tests = [@test]
15
18
 
@@ -166,9 +169,35 @@ class TestRailsAutotest < TestAutotest
166
169
  util_tests_for_file('Rakefile')
167
170
  end
168
171
 
172
+ def test_consolidate_failures_multiple_matches_before
173
+ @test_class = 'BlahTest'
174
+ @a.files.clear
175
+ @a.files['app/model/blah.rb'] = Time.at(42)
176
+ @a.files['app/model/different_blah.rb'] = Time.at(42)
177
+ @a.files['test/unit/blah_test.rb'] = Time.at(42)
178
+ @a.files['test/unit/different_blah_test.rb'] = Time.at(42)
179
+ result = @a.consolidate_failures([['test_matched', @test_class]])
180
+ expected = { 'test/unit/blah_test.rb' => [ 'test_matched' ] }
181
+ assert_equal expected, result
182
+ assert_equal "", @a.output.string
183
+ end
184
+
169
185
  def util_tests_for_file(file, *expected)
170
186
  assert_equal(expected.flatten.sort.uniq,
171
187
  @a.tests_for_file(file).sort.uniq, "tests for #{file}")
172
188
  end
189
+
190
+ def test_path_to_classname
191
+ # rails
192
+ util_path_to_classname 'BlahTest', 'test/blah_test.rb'
193
+ util_path_to_classname 'BlahTest', 'test/unit/blah_test.rb'
194
+ util_path_to_classname 'BlahTest', 'test/functional/blah_test.rb'
195
+ util_path_to_classname 'BlahTest', 'test/integration/blah_test.rb'
196
+ util_path_to_classname 'BlahTest', 'test/views/blah_test.rb'
197
+ util_path_to_classname 'BlahTest', 'test/controllers/blah_test.rb'
198
+ util_path_to_classname 'BlahTest', 'test/helpers/blah_test.rb'
199
+
200
+ util_path_to_classname 'OuterTest::InnerTest', 'test/controllers/outer/inner_test.rb'
201
+ end
173
202
  end
174
203
 
@@ -0,0 +1,39 @@
1
+ require 'test/unit'
2
+ require 'test/zentest_assertions'
3
+ require 'test/rails'
4
+
5
+ begin
6
+ module TRHelper
7
+ def tr_helper; end
8
+ end
9
+ class TRHelperTest < Test::Rails::HelperTestCase; end
10
+ rescue RuntimeError
11
+ end
12
+
13
+ begin
14
+ module Widgets; end
15
+ module Widgets::SomeHelper
16
+ def widgets_some_helper; end
17
+ end
18
+ class Widgets::SomeHelperTest < Test::Rails::HelperTestCase; end
19
+ rescue RuntimeError
20
+ end
21
+
22
+ class TestRailsHelperTestCase < Test::Unit::TestCase
23
+
24
+ def test_self_inherited
25
+ assert defined? TRHelperTest
26
+
27
+ assert_includes TRHelperTest.instance_methods, 'tr_helper'
28
+ end
29
+
30
+ def test_self_inherited_namespaced
31
+ assert defined? Widgets
32
+ assert defined? Widgets::SomeHelperTest
33
+
34
+ assert_includes Widgets::SomeHelperTest.instance_methods,
35
+ 'widgets_some_helper'
36
+ end
37
+
38
+ end
39
+
@@ -0,0 +1,54 @@
1
+ require 'test/unit'
2
+ require 'test/zentest_assertions'
3
+ require 'test/rails'
4
+
5
+ class View; end
6
+
7
+ class TestRailsViewTestCase < Test::Rails::ViewTestCase
8
+
9
+ def setup
10
+ # override
11
+ @request = Object.new
12
+ def @request.body; @body; end
13
+ def @request.body=(body); @body = body; end
14
+
15
+ @assert_tag = []
16
+ end
17
+
18
+ def test_assert_text_area
19
+ @request.body = <<-EOF
20
+ <form action="/post/save">
21
+ <textarea id="post_body" name="post[body]">
22
+ OMG he like hates me and he's like going out with this total skank!~ oh noes!!~
23
+ </textarea>
24
+ </form>
25
+ EOF
26
+
27
+ assert_text_area '/post/save', 'post[body]'
28
+
29
+ expected = {
30
+ :tag => 'form', :attributes => { :action => '/post/save' },
31
+ :descendant => {
32
+ :tag => 'textarea', :attributes => { :name => 'post[body]' } } }
33
+
34
+ assert_equal expected, @assert_tag.first
35
+
36
+ assert_text_area '/post/save', 'post[body]',
37
+ "OMG he like hates me and he's like going out with this total skank!~ oh noes!!~"
38
+
39
+ expected = {
40
+ :tag => 'form', :attributes => { :action => '/post/save' },
41
+ :descendant => {
42
+ :tag => 'textarea', :attributes => { :name => 'post[body]' },
43
+ :content =>
44
+ "OMG he like hates me and he's like going out with this total skank!~ oh noes!!~" } }
45
+
46
+ assert_equal expected, @assert_tag.last
47
+ end
48
+
49
+ def assert_tag(arg)
50
+ @assert_tag << arg
51
+ end
52
+
53
+ end
54
+
@@ -5,7 +5,7 @@ require 'test/unit' unless defined? $ZENTEST and $ZENTEST
5
5
  $TESTING = true
6
6
 
7
7
  # I do this so I can still run ZenTest against the tests and itself...
8
- require 'ZenTest' unless defined? $ZENTEST
8
+ require 'zentest' unless defined? $ZENTEST
9
9
 
10
10
  # These are just classes set up for quick testing.
11
11
  # TODO: need to test a compound class name Mod::Cls
metadata CHANGED
@@ -1,43 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11.15
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: ZenTest
5
5
  version: !ruby/object:Gem::Version
6
- version: 3.4.0
7
- date: 2006-09-12 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.
6
+ version: 3.4.1
7
+ date: 2006-10-13 00:00:00 -07:00
8
+ summary: "ZenTest provides 4 different tools and 1 library: zentest, unit_diff, autotest, multiruby, and Test::Rails."
12
9
  require_paths:
13
10
  - lib
11
+ - test
14
12
  email: ryand-ruby@zenspider.com
15
13
  homepage: http://www.zenspider.com/ZSS/Products/ZenTest/
16
14
  rubyforge_project: zentest
17
- description: |-
18
- ZenTest provides 4 different tools and 1 library: zentest, unit_diff,
19
- autotest, multiruby, and Test::Rails.
20
-
21
- ZenTest scans your target and unit-test code and writes your missing
22
- code based on simple naming rules, enabling XP at a much quicker
23
- pace. ZenTest only works with Ruby and Test::Unit.
24
-
25
- unit_diff is a command-line filter to diff expected results from
26
- actual results and allow you to quickly see exactly what is wrong.
27
-
28
- autotest is a continous testing facility meant to be used during
29
- development. As soon as you save a file, autotest will run the
30
- corresponding dependent tests.
31
-
32
- multiruby runs anything you want on multiple versions of ruby. Great
33
- for compatibility checking!
34
-
35
- Test::Rails helps you build industrial-strength Rails code.
36
-
37
- == STRATEGERY
38
-
39
- There are two strategeries intended for ZenTest: test conformance
40
- auditing and rapid XP.
15
+ 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! Test::Rails helps you build industrial-strength Rails code."
41
16
  autorequire:
42
17
  default_executable:
43
18
  bindir: bin
@@ -97,7 +72,10 @@ files:
97
72
  - lib/unit_diff.rb
98
73
  - lib/zentest.rb
99
74
  - test/test_autotest.rb
75
+ - test/test_help.rb
100
76
  - test/test_rails_autotest.rb
77
+ - test/test_rails_helper_test_case.rb
78
+ - test/test_rails_view_test_case.rb
101
79
  - test/test_ruby_fork.rb
102
80
  - test/test_unit_diff.rb
103
81
  - test/test_zentest.rb
@@ -120,5 +98,13 @@ extensions: []
120
98
 
121
99
  requirements: []
122
100
 
123
- dependencies: []
124
-
101
+ dependencies:
102
+ - !ruby/object:Gem::Dependency
103
+ name: hoe
104
+ version_requirement:
105
+ version_requirements: !ruby/object:Gem::Version::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 1.1.1
110
+ version: