ryanbriones-ZenTest 3.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/History.txt +523 -0
  2. data/Manifest.txt +69 -0
  3. data/README.txt +110 -0
  4. data/Rakefile +68 -0
  5. data/articles/Article.css +721 -0
  6. data/articles/getting_started_with_autotest.html +532 -0
  7. data/articles/how_to_use_zentest.txt +393 -0
  8. data/bin/autotest +55 -0
  9. data/bin/multiruby +40 -0
  10. data/bin/multiruby_setup +68 -0
  11. data/bin/rails_test_audit +80 -0
  12. data/bin/unit_diff +38 -0
  13. data/bin/zentest +28 -0
  14. data/example.txt +42 -0
  15. data/example1.rb +7 -0
  16. data/example2.rb +15 -0
  17. data/example_dot_autotest.rb +45 -0
  18. data/lib/autotest.rb +654 -0
  19. data/lib/autotest/autoupdate.rb +26 -0
  20. data/lib/autotest/camping.rb +37 -0
  21. data/lib/autotest/cctray.rb +57 -0
  22. data/lib/autotest/discover.rb +6 -0
  23. data/lib/autotest/emacs.rb +35 -0
  24. data/lib/autotest/email_notify.rb +66 -0
  25. data/lib/autotest/fixtures.rb +12 -0
  26. data/lib/autotest/growl.rb +28 -0
  27. data/lib/autotest/heckle.rb +14 -0
  28. data/lib/autotest/html_report.rb +31 -0
  29. data/lib/autotest/jabber_notify.rb +111 -0
  30. data/lib/autotest/kdenotify.rb +14 -0
  31. data/lib/autotest/menu.rb +51 -0
  32. data/lib/autotest/migrate.rb +7 -0
  33. data/lib/autotest/notify.rb +34 -0
  34. data/lib/autotest/once.rb +9 -0
  35. data/lib/autotest/pretty.rb +83 -0
  36. data/lib/autotest/rails.rb +81 -0
  37. data/lib/autotest/rcov.rb +22 -0
  38. data/lib/autotest/redgreen.rb +21 -0
  39. data/lib/autotest/restart.rb +11 -0
  40. data/lib/autotest/screen.rb +73 -0
  41. data/lib/autotest/shame.rb +45 -0
  42. data/lib/autotest/snarl.rb +51 -0
  43. data/lib/autotest/timestamp.rb +9 -0
  44. data/lib/functional_test_matrix.rb +92 -0
  45. data/lib/multiruby.rb +401 -0
  46. data/lib/test/rails.rb +295 -0
  47. data/lib/test/rails/controller_test_case.rb +382 -0
  48. data/lib/test/rails/functional_test_case.rb +79 -0
  49. data/lib/test/rails/helper_test_case.rb +64 -0
  50. data/lib/test/rails/ivar_proxy.rb +31 -0
  51. data/lib/test/rails/pp_html_document.rb +74 -0
  52. data/lib/test/rails/rake_tasks.rb +50 -0
  53. data/lib/test/rails/render_tree.rb +93 -0
  54. data/lib/test/rails/test_case.rb +28 -0
  55. data/lib/test/rails/view_test_case.rb +597 -0
  56. data/lib/test/zentest_assertions.rb +134 -0
  57. data/lib/unit_diff.rb +259 -0
  58. data/lib/zentest.rb +566 -0
  59. data/lib/zentest_mapping.rb +99 -0
  60. data/test/test_autotest.rb +449 -0
  61. data/test/test_help.rb +36 -0
  62. data/test/test_rails_autotest.rb +229 -0
  63. data/test/test_rails_controller_test_case.rb +58 -0
  64. data/test/test_rails_helper_test_case.rb +48 -0
  65. data/test/test_rails_view_test_case.rb +275 -0
  66. data/test/test_unit_diff.rb +319 -0
  67. data/test/test_zentest.rb +566 -0
  68. data/test/test_zentest_assertions.rb +128 -0
  69. data/test/test_zentest_mapping.rb +222 -0
  70. metadata +151 -0
data/test/test_help.rb ADDED
@@ -0,0 +1,36 @@
1
+ # ActionPack
2
+ module ActionController; end
3
+ module ActionController::Flash; end
4
+ class ActionController::Flash::FlashHash < Hash; end
5
+ class ActionController::TestSession < Hash; end
6
+
7
+ class ActionController::TestRequest
8
+ attr_accessor :session
9
+ end
10
+ class ActionController::TestResponse; end
11
+
12
+ class ApplicationController; end
13
+
14
+ module ActionView; end
15
+ module ActionView::Helpers; end
16
+ module ActionView::Helpers::ActiveRecordHelper; end
17
+ module ActionView::Helpers::TagHelper; end
18
+ module ActionView::Helpers::TextHelper; end
19
+ module ActionView::Helpers::FormTagHelper; end
20
+ module ActionView::Helpers::FormOptionsHelper; end
21
+ module ActionView::Helpers::FormHelper; end
22
+ module ActionView::Helpers::UrlHelper; end
23
+ module ActionView::Helpers::AssetTagHelper; end
24
+
25
+ class << Test::Unit::TestCase
26
+ attr_accessor :use_transactional_fixtures
27
+ attr_accessor :use_instantiated_fixtures
28
+ end
29
+
30
+ # ActionMailer
31
+ module ActionMailer; end
32
+ class ActionMailer::Base
33
+ def self.deliveries=(arg); end unless defined? @@defined
34
+ @@defined = true
35
+ end
36
+
@@ -0,0 +1,229 @@
1
+ require 'test/unit' if $0 == __FILE__
2
+ require 'test/test_autotest'
3
+ require 'autotest/rails'
4
+
5
+ class TestRailsAutotest < TestAutotest
6
+
7
+ def setup
8
+ super
9
+
10
+ @test_class = 'RouteTest'
11
+ @test = 'test/unit/route_test.rb'
12
+ @other_test = 'test/other_blah_test.rb'
13
+ @impl = 'app/models/route.rb'
14
+ @inner_test = 'test/outer/inner_test.rb'
15
+ @outer_test = 'test/outer_test.rb'
16
+ @inner_test_class = "OuterTest::InnerTest"
17
+
18
+ @rails_unit_tests = [@test]
19
+
20
+ @rails_controller_tests = %w(test/controllers/admin/themes_controller_test.rb
21
+ test/controllers/articles_controller_test.rb
22
+ test/controllers/dummy_controller_test.rb
23
+ test/controllers/route_controller_test.rb)
24
+
25
+ @rails_view_tests = %w(test/views/admin/themes_view_test.rb
26
+ test/views/articles_view_test.rb
27
+ test/views/layouts_view_test.rb
28
+ test/views/route_view_test.rb)
29
+
30
+ @rails_functional_tests = %w(test/functional/admin/themes_controller_test.rb
31
+ test/functional/articles_controller_test.rb
32
+ test/functional/dummy_controller_test.rb
33
+ test/functional/route_controller_test.rb)
34
+
35
+ # These files aren't put in @file_map, so add them to it
36
+ @extra_files = %w(test/controllers/admin/themes_controller_test.rb
37
+ test/controllers/articles_controller_test.rb
38
+ test/controllers/dummy_controller_test.rb
39
+ test/functional/articles_controller_test.rb
40
+ test/functional/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
+
45
+ @files.clear
46
+
47
+ (@rails_unit_tests +
48
+ @rails_controller_tests +
49
+ @rails_view_tests +
50
+ @rails_functional_tests +
51
+ @extra_files +
52
+ [@impl]).flatten.each_with_index do |path, t|
53
+ @files[path] = Time.at(t+1)
54
+ end
55
+
56
+ @a.find_order = @files.keys
57
+ @a.last_mtime = @files.values.sort.last
58
+ end
59
+
60
+ # Overridden from superclass... the scenario just doesn't happen the same way.
61
+ def test_consolidate_failures_multiple_matches
62
+ @test2 = 'test/unit/route_again_test.rb'
63
+ @files[@test2] = Time.at(42)
64
+ @files['app/views/routes/edit.rhtml'] = Time.at(42)
65
+ @files['app/views/routes/list.rhtml'] = Time.at(42)
66
+
67
+ @a.find_order = @files.keys
68
+
69
+ result = @a.consolidate_failures([['test_unmatched', @test_class]])
70
+ expected = {"test/unit/route_test.rb"=>["test_unmatched"]}
71
+ assert_equal expected, result
72
+ assert_equal '', @a.output.string
73
+ end
74
+
75
+ def test_reorder_random
76
+ @a.order = :random
77
+
78
+ srand 42
79
+ expected, size = @files.dup, @files.size
80
+ expected = expected.sort_by { rand(size) }
81
+
82
+ srand 42
83
+ result = @a.reorder(@files.dup)
84
+
85
+ assert_equal expected, result
86
+ end
87
+
88
+ def test_test_files_for
89
+ empty = []
90
+ assert_equal empty, @a.test_files_for('blah.rb')
91
+ assert_equal empty, @a.test_files_for('test_blah.rb')
92
+
93
+ # controllers
94
+ util_test_files_for('app/controllers/admin/themes_controller.rb',
95
+ 'test/controllers/admin/themes_controller_test.rb',
96
+ 'test/functional/admin/themes_controller_test.rb')
97
+
98
+ util_test_files_for('app/controllers/application.rb',
99
+ @rails_controller_tests,
100
+ @rails_view_tests,
101
+ @rails_functional_tests)
102
+
103
+ util_test_files_for('app/controllers/route_controller.rb',
104
+ 'test/controllers/route_controller_test.rb',
105
+ 'test/functional/route_controller_test.rb')
106
+
107
+ util_test_files_for('app/controllers/notest_controller.rb')
108
+
109
+ # helpers
110
+ util_test_files_for('app/helpers/application_helper.rb',
111
+ @rails_view_tests,
112
+ @rails_functional_tests)
113
+
114
+ util_test_files_for('app/helpers/route_helper.rb',
115
+ 'test/views/route_view_test.rb',
116
+ 'test/functional/route_controller_test.rb')
117
+
118
+ # model
119
+ util_test_files_for('app/models/route.rb',
120
+ @test)
121
+
122
+ util_test_files_for('app/models/notest.rb')
123
+
124
+ # views
125
+ util_test_files_for('app/views/layouts/default.rhtml',
126
+ 'test/views/layouts_view_test.rb')
127
+
128
+ util_test_files_for('app/views/route/index.rhtml',
129
+ 'test/views/route_view_test.rb',
130
+ 'test/functional/route_controller_test.rb')
131
+
132
+ util_test_files_for('app/views/route/xml.rxml',
133
+ 'test/views/route_view_test.rb',
134
+ 'test/functional/route_controller_test.rb')
135
+
136
+ util_test_files_for('app/views/shared/notest.rhtml')
137
+
138
+ util_test_files_for('app/views/articles/flag.rhtml',
139
+ 'test/views/articles_view_test.rb',
140
+ 'test/functional/articles_controller_test.rb')
141
+
142
+ # tests
143
+ util_test_files_for('test/fixtures/routes.yml',
144
+ @test,
145
+ 'test/controllers/route_controller_test.rb',
146
+ 'test/views/route_view_test.rb',
147
+ 'test/functional/route_controller_test.rb')
148
+
149
+ util_test_files_for('test/test_helper.rb',
150
+ @rails_unit_tests, @rails_controller_tests,
151
+ @rails_view_tests, @rails_functional_tests)
152
+
153
+ util_test_files_for(@test, @test)
154
+
155
+ util_test_files_for('test/controllers/route_controller_test.rb',
156
+ 'test/controllers/route_controller_test.rb')
157
+
158
+ util_test_files_for('test/views/route_view_test.rb',
159
+ 'test/views/route_view_test.rb')
160
+
161
+ util_test_files_for('test/functional/route_controller_test.rb',
162
+ 'test/functional/route_controller_test.rb')
163
+
164
+ util_test_files_for('test/functional/admin/themes_controller_test.rb',
165
+ 'test/functional/admin/themes_controller_test.rb')
166
+
167
+ # global conf thingies
168
+ util_test_files_for('config/boot.rb',
169
+ @rails_unit_tests, @rails_controller_tests,
170
+ @rails_view_tests, @rails_functional_tests)
171
+
172
+ util_test_files_for('config/database.yml',
173
+ @rails_unit_tests, @rails_controller_tests,
174
+ @rails_view_tests, @rails_functional_tests)
175
+
176
+ util_test_files_for('config/environment.rb',
177
+ @rails_unit_tests, @rails_controller_tests,
178
+ @rails_view_tests, @rails_functional_tests)
179
+
180
+ util_test_files_for('config/environments/test.rb',
181
+ @rails_unit_tests, @rails_controller_tests,
182
+ @rails_view_tests, @rails_functional_tests)
183
+
184
+ util_test_files_for('config/routes.rb',
185
+ @rails_controller_tests,
186
+ @rails_view_tests, @rails_functional_tests)
187
+
188
+ # ignored crap
189
+ util_test_files_for('vendor/plugins/cartographer/lib/keys.rb')
190
+
191
+ util_test_files_for('Rakefile')
192
+ end
193
+
194
+ def test_consolidate_failures_multiple_matches_before
195
+ @test_class = 'BlahTest'
196
+ @files.clear
197
+ @files['app/model/blah.rb'] = Time.at(42)
198
+ @files['app/model/different_blah.rb'] = Time.at(42)
199
+ @files['test/unit/blah_test.rb'] = Time.at(42)
200
+ @files['test/unit/different_blah_test.rb'] = Time.at(42)
201
+
202
+ @a.find_order = @files.keys
203
+
204
+ result = @a.consolidate_failures([['test_matched', @test_class]])
205
+ expected = { 'test/unit/blah_test.rb' => [ 'test_matched' ] }
206
+ assert_equal expected, result
207
+ assert_equal "", @a.output.string
208
+ end
209
+
210
+ def util_test_files_for(file, *expected)
211
+ assert_equal(expected.flatten.sort.uniq,
212
+ @a.test_files_for(file).sort.uniq, "tests for #{file}")
213
+ end
214
+
215
+ def test_path_to_classname
216
+ # rails
217
+ util_path_to_classname 'BlahTest', 'test/blah_test.rb'
218
+ util_path_to_classname 'BlahTest', 'test/unit/blah_test.rb'
219
+ util_path_to_classname 'BlahTest', 'test/functional/blah_test.rb'
220
+ util_path_to_classname 'BlahTest', 'test/integration/blah_test.rb'
221
+ util_path_to_classname 'BlahTest', 'test/views/blah_test.rb'
222
+ util_path_to_classname 'BlahTest', 'test/controllers/blah_test.rb'
223
+ util_path_to_classname 'BlahTest', 'test/helpers/blah_test.rb'
224
+
225
+ util_path_to_classname('OuterTest::InnerTest',
226
+ 'test/controllers/outer/inner_test.rb')
227
+ end
228
+ end
229
+
@@ -0,0 +1,58 @@
1
+ require 'test/unit'
2
+ require 'test/zentest_assertions'
3
+
4
+ unless defined? $TESTING_RTC then
5
+ $TESTING_RTC = true
6
+
7
+ begin
8
+ require 'test/rails'
9
+ rescue LoadError, NameError
10
+ $TESTING_RTC = false
11
+ end
12
+ end
13
+
14
+ class TRController < ApplicationController
15
+ end if $TESTING_RTC
16
+
17
+ class TestRailsControllerTestCase < Test::Rails::ControllerTestCase
18
+
19
+ def setup
20
+ @controller_class_name = 'TRController'
21
+ super
22
+ end
23
+
24
+ def assigns
25
+ { 'ivar' => 'value' }
26
+ end
27
+
28
+ def test_assert_assigned
29
+ assert_assigned :ivar
30
+ assert_assigned :ivar, 'value'
31
+
32
+ assert_raise Test::Unit::AssertionFailedError do
33
+ assert_assigned :no_ivar
34
+ end
35
+
36
+ e = assert_raise Test::Unit::AssertionFailedError do
37
+ assert_assigned :ivar, 'bad_value'
38
+ end
39
+
40
+ expected = <<-EOF.strip
41
+ assert_assigned :ivar.
42
+ <\"bad_value\"> expected but was
43
+ <\"value\">.
44
+ EOF
45
+
46
+ assert_equal expected, e.message
47
+ end
48
+
49
+ def test_deny_assigned
50
+ deny_assigned :no_ivar
51
+
52
+ assert_raise Test::Unit::AssertionFailedError do
53
+ deny_assigned :ivar
54
+ end
55
+ end
56
+
57
+ end if $TESTING_RTC
58
+
@@ -0,0 +1,48 @@
1
+ require 'test/unit'
2
+ require 'test/zentest_assertions'
3
+
4
+ unless defined? $TESTING_RTC then
5
+ $TESTING_RTC = true
6
+
7
+ begin
8
+ require 'test/rails'
9
+ rescue LoadError, NameError
10
+ $TESTING_RTC = false
11
+ end
12
+ end
13
+
14
+ begin
15
+ module TRHelper
16
+ def tr_helper; end
17
+ end
18
+ class TRHelperTest < Test::Rails::HelperTestCase; end
19
+ rescue RuntimeError
20
+ end if $TESTING_RTC
21
+
22
+ begin
23
+ module Widgets; end
24
+ module Widgets::SomeHelper
25
+ def widgets_some_helper; end
26
+ end
27
+ class Widgets::SomeHelperTest < Test::Rails::HelperTestCase; end
28
+ rescue RuntimeError
29
+ end if $TESTING_RTC
30
+
31
+ class TestRailsHelperTestCase < Test::Unit::TestCase
32
+
33
+ def test_self_inherited
34
+ assert defined? TRHelperTest
35
+
36
+ assert_includes TRHelperTest.instance_methods, 'tr_helper'
37
+ end
38
+
39
+ def test_self_inherited_namespaced
40
+ assert defined? Widgets
41
+ assert defined? Widgets::SomeHelperTest
42
+
43
+ assert_includes(Widgets::SomeHelperTest.instance_methods,
44
+ 'widgets_some_helper')
45
+ end
46
+
47
+ end if $TESTING_RTC
48
+
@@ -0,0 +1,275 @@
1
+ require 'test/unit'
2
+ require 'test/zentest_assertions'
3
+
4
+ unless defined? $TESTING_RTC then
5
+ $TESTING_RTC = true
6
+
7
+ begin
8
+ require 'test/rails'
9
+ rescue LoadError, NameError
10
+ $TESTING_RTC = false
11
+ end
12
+ end
13
+
14
+ module Rails
15
+ module VERSION
16
+ STRING = '99.99.99' unless defined? STRING # HACK
17
+ end
18
+ end
19
+
20
+ class TestRailsViewTestCase < Test::Rails::ViewTestCase
21
+
22
+ def setup
23
+ @assert_tag = []
24
+ @assert_no_tag = []
25
+
26
+ @assert_select = []
27
+ end
28
+
29
+ def test_assert_field
30
+ assert_field :text, :game, :amount
31
+
32
+ assert_equal 2, @assert_select.length
33
+
34
+ expected = ["input[type='text'][name='game[amount]']"]
35
+
36
+ assert_equal expected, @assert_select.first
37
+
38
+ expected = ["label[for='game_amount']"]
39
+
40
+ assert_equal expected, @assert_select.last
41
+ end
42
+
43
+ def test_assert_field_form
44
+ assert_field '/game/save', :text, :game, :amount
45
+
46
+ assert_equal 4, @assert_select.length
47
+
48
+ assert_equal @assert_select.shift, ["form[action='/game/save']"]
49
+ assert_equal(@assert_select.shift,
50
+ ["input[type='text'][name='game[amount]']"])
51
+
52
+ assert_equal @assert_select.shift, ["form[action='/game/save']"]
53
+ assert_equal @assert_select.shift, ["label[for='game_amount']"]
54
+ end
55
+
56
+ def test_assert_form
57
+ assert_form '/game/save'
58
+
59
+ assert_equal 1, @assert_select.length
60
+ assert_equal ["form[action='/game/save']"], @assert_select.first
61
+ end
62
+
63
+ def test_assert_form_method
64
+ assert_form '/game/save', :post
65
+
66
+ assert_equal 1, @assert_select.length
67
+ assert_equal ["form[action='/game/save'][method='post']"],
68
+ @assert_select.first
69
+ end
70
+
71
+ def test_assert_form_enctype
72
+ assert_form '/game/save', nil, 'multipart/form-data'
73
+
74
+ assert_equal 1, @assert_select.length
75
+ assert_equal ["form[action='/game/save'][enctype='multipart/form-data']"],
76
+ @assert_select.first
77
+ end
78
+
79
+ def test_assert_h
80
+ assert_h 1, 'hi'
81
+
82
+ assert_equal [['h1', { :text => 'hi' }]], @assert_select
83
+ end
84
+
85
+ def test_assert_img
86
+ assert_image '/images/bucket.jpg'
87
+
88
+ assert_equal [["img[src='/images/bucket.jpg']"]], @assert_select
89
+ end
90
+
91
+ def test_assert_input
92
+ assert_input :text, 'game[amount]'
93
+
94
+ assert_equal 1, @assert_select.length
95
+ assert_equal ["input[type='text'][name='game[amount]']"],
96
+ @assert_select.first
97
+ end
98
+
99
+ def test_assert_input_form
100
+ assert_input '/game/save', :text, 'game[amount]'
101
+
102
+ assert_equal 2, @assert_select.length
103
+ assert_equal ["form[action='/game/save']"], @assert_select.shift
104
+ assert_equal ["input[type='text'][name='game[amount]']"],
105
+ @assert_select.shift
106
+ end
107
+
108
+ def test_assert_input_value
109
+ assert_input :text, 'game[amount]', 5
110
+
111
+ expected = ["input[type='text'][name='game[amount]'][value='5']"]
112
+
113
+ assert_equal 1, @assert_select.length
114
+ assert_equal expected, @assert_select.first
115
+ end
116
+
117
+ def test_assert_label
118
+ assert_label 'game_amount'
119
+
120
+ expected = ["label[for='game_amount']"]
121
+
122
+ assert_equal 1, @assert_select.length
123
+ assert_equal expected, @assert_select.first
124
+ end
125
+
126
+ def test_assert_label_form
127
+ assert_label '/game/save', 'game_amount'
128
+
129
+ assert_equal 2, @assert_select.length
130
+ assert_equal ["form[action='/game/save']"], @assert_select.shift
131
+ assert_equal ["label[for='game_amount']"], @assert_select.shift
132
+ end
133
+
134
+ def test_assert_links_to
135
+ assert_links_to '/game/show/1', 'hi'
136
+
137
+ expected = ["a[href='/game/show/1']", { :text => 'hi' }]
138
+
139
+
140
+ assert_equal 1, @assert_select.length
141
+ assert_equal expected, @assert_select.first
142
+ end
143
+
144
+ def test_assert_multipart_form
145
+ assert_multipart_form '/game/save'
146
+
147
+ expected = [
148
+ "form[action='/game/save'][method='post'][enctype='multipart/form-data']"
149
+ ]
150
+
151
+ assert_equal 1, @assert_select.length
152
+ assert_equal expected, @assert_select.first
153
+ end
154
+
155
+ def test_assert_post_form
156
+ assert_post_form '/game/save'
157
+
158
+ expected = ["form[action='/game/save'][method='post']"]
159
+
160
+ assert_equal 1, @assert_select.length
161
+ assert_equal expected, @assert_select.first
162
+ end
163
+
164
+ def test_assert_select_tag
165
+ assert_select_tag :game, :location_id,
166
+ 'Ballet' => 1, 'Guaymas' => 2
167
+
168
+ assert_equal 2, @assert_select.length
169
+
170
+ assert_include(@assert_select,
171
+ ["select[name='game[location_id]'] option[value='2']",
172
+ { :text => 'Guaymas' }])
173
+ assert_include(@assert_select,
174
+ ["select[name='game[location_id]'] option[value='1']",
175
+ { :text => 'Ballet' }])
176
+ end
177
+
178
+ def test_assert_select_tag_form
179
+ assert_select_tag '/game/save', :game, :location_id,
180
+ 'Ballet' => 1, 'Guaymas' => 2
181
+
182
+ assert_equal 4, @assert_select.length
183
+
184
+ assert_include @assert_select, ["form[action='/game/save']"]
185
+ assert_include(@assert_select,
186
+ ["select[name='game[location_id]'] option[value='2']",
187
+ { :text => 'Guaymas' }])
188
+ assert_include @assert_select, ["form[action='/game/save']"]
189
+ assert_include(@assert_select,
190
+ ["select[name='game[location_id]'] option[value='1']",
191
+ { :text => 'Ballet' }])
192
+ end
193
+
194
+ def test_assert_submit
195
+ assert_submit 'Save!'
196
+
197
+ assert_equal 1, @assert_select.length
198
+ assert_equal ["input[type='submit'][value='Save!']"], @assert_select.first
199
+ end
200
+
201
+ def test_assert_submit_form
202
+ assert_submit '/game/save', 'Save!'
203
+
204
+ assert_equal 2, @assert_select.length
205
+ assert_equal ["form[action='/game/save']"], @assert_select.shift
206
+ assert_equal ["input[type='submit'][value='Save!']"], @assert_select.shift
207
+ end
208
+
209
+ def test_assert_tag_in_form
210
+ assert_tag_in_form '/game/save', :tag => 'input'
211
+
212
+ expected = {
213
+ :tag => "form",
214
+ :attributes => { :action => "/game/save" },
215
+ :descendant => { :tag => "input" },
216
+ }
217
+
218
+ assert_equal 1, @assert_tag.length
219
+ assert_equal expected, @assert_tag.first
220
+ end
221
+
222
+ def test_assert_text_area
223
+ assert_text_area 'post[body]'
224
+
225
+ assert_equal 1, @assert_select.length
226
+ assert_equal ["textarea[name='post[body]']"], @assert_select.shift
227
+ end
228
+
229
+ def test_assert_text_area_body
230
+ assert_text_area 'post[body]', 'OMG!1! that skank stole my BF!~1!'
231
+
232
+ assert_equal 1, @assert_select.length
233
+ assert_equal ["textarea[name='post[body]']",
234
+ { :text => 'OMG!1! that skank stole my BF!~1!' }],
235
+ @assert_select.shift
236
+ end
237
+
238
+ def test_assert_text_area_form
239
+ assert_text_area '/post/save', 'post[body]'
240
+
241
+ assert_equal 2, @assert_select.length
242
+ assert_equal ["form[action='/post/save']"], @assert_select.shift
243
+ assert_equal ["textarea[name='post[body]']"], @assert_select.shift
244
+ end
245
+
246
+ def test_assert_title
247
+ assert_title 'hi'
248
+
249
+ assert_equal [['title', { :text => 'hi' }]], @assert_select
250
+ end
251
+
252
+ def test_deny_links_to
253
+ deny_links_to '/game/show/1', 'hi'
254
+
255
+ expected = ["a[href='/game/show/1']", { :text => 'hi', :count => 0 }]
256
+
257
+ assert_equal 1, @assert_select.length
258
+ assert_equal expected, @assert_select.first
259
+ end
260
+
261
+ def assert_tag(arg)
262
+ @assert_tag << arg
263
+ end
264
+
265
+ def assert_no_tag(arg)
266
+ @assert_no_tag << arg
267
+ end
268
+
269
+ def assert_select(*args)
270
+ @assert_select << args
271
+ yield if block_given?
272
+ end
273
+
274
+ end if $TESTING_RTC
275
+