SlimZenTest 4.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,242 @@
1
+ $TESTING = true
2
+
3
+ require 'rubygems'
4
+ require 'minitest/autorun'
5
+
6
+ require 'zentest_mapping' unless defined? $ZENTEST
7
+
8
+ class Dummy
9
+ attr_accessor :inherited_methods
10
+ include ZenTestMapping
11
+ end
12
+
13
+ class TestZentestMapping < MiniTest::Unit::TestCase
14
+ def setup
15
+ @tester = Dummy.new
16
+ end
17
+
18
+ def util_simple_setup
19
+ klasses = {
20
+ "Something" => {
21
+ "method1" => true,
22
+ "method1!" => true,
23
+ "method1=" => true,
24
+ "method1?" => true,
25
+ "attrib" => true,
26
+ "attrib=" => true,
27
+ "equal?" => true,
28
+ "self.method3" => true,
29
+ "self.[]" => true,
30
+ },
31
+ }
32
+ test_klasses = {
33
+ "TestSomething" => {
34
+ "test_class_method4" => true,
35
+ "test_method2" => true,
36
+ "setup" => true,
37
+ "teardown" => true,
38
+ "test_class_index" => true,
39
+ },
40
+ }
41
+ @tester.inherited_methods = test_klasses.merge(klasses)
42
+ @generated_code = "
43
+ require 'test/unit' unless defined? $ZENTEST and $ZENTEST
44
+
45
+ class Something
46
+ def self.method4(*args)
47
+ raise NotImplementedError, 'Need to write self.method4'
48
+ end
49
+
50
+ def method2(*args)
51
+ raise NotImplementedError, 'Need to write method2'
52
+ end
53
+ end
54
+
55
+ class TestSomething < Test::Unit::TestCase
56
+ def test_class_method3
57
+ raise NotImplementedError, 'Need to write test_class_method3'
58
+ end
59
+
60
+ def test_attrib
61
+ raise NotImplementedError, 'Need to write test_attrib'
62
+ end
63
+
64
+ def test_attrib_equals
65
+ raise NotImplementedError, 'Need to write test_attrib_equals'
66
+ end
67
+
68
+ def test_equal_eh
69
+ raise NotImplementedError, 'Need to write test_equal_eh'
70
+ end
71
+
72
+ def test_method1
73
+ raise NotImplementedError, 'Need to write test_method1'
74
+ end
75
+
76
+ def test_method1_bang
77
+ raise NotImplementedError, 'Need to write test_method1_bang'
78
+ end
79
+
80
+ def test_method1_eh
81
+ raise NotImplementedError, 'Need to write test_method1_eh'
82
+ end
83
+
84
+ def test_method1_equals
85
+ raise NotImplementedError, 'Need to write test_method1_equals'
86
+ end
87
+ end
88
+
89
+ # Number of errors detected: 10
90
+ "
91
+ end
92
+
93
+ def test_normal_to_test
94
+ self.util_simple_setup
95
+ assert_equal("test_method1", @tester.normal_to_test("method1"))
96
+ assert_equal("test_method1_bang", @tester.normal_to_test("method1!"))
97
+ assert_equal("test_method1_eh", @tester.normal_to_test("method1?"))
98
+ assert_equal("test_method1_equals", @tester.normal_to_test("method1="))
99
+ end
100
+
101
+ def test_normal_to_test_cls
102
+ self.util_simple_setup
103
+ assert_equal("test_class_method1",
104
+ @tester.normal_to_test("self.method1"))
105
+ assert_equal("test_class_method1_bang",
106
+ @tester.normal_to_test("self.method1!"))
107
+ assert_equal("test_class_method1_eh",
108
+ @tester.normal_to_test("self.method1?"))
109
+ assert_equal("test_class_method1_equals",
110
+ @tester.normal_to_test("self.method1="))
111
+ end
112
+
113
+ def test_normal_to_test_operators
114
+ self.util_simple_setup
115
+ assert_equal("test_and", @tester.normal_to_test("&"))
116
+ assert_equal("test_bang", @tester.normal_to_test("!"))
117
+ assert_equal("test_carat", @tester.normal_to_test("^"))
118
+ assert_equal("test_div", @tester.normal_to_test("/"))
119
+ assert_equal("test_equalstilde", @tester.normal_to_test("=~"))
120
+ assert_equal("test_minus", @tester.normal_to_test("-"))
121
+ assert_equal("test_or", @tester.normal_to_test("|"))
122
+ assert_equal("test_percent", @tester.normal_to_test("%"))
123
+ assert_equal("test_plus", @tester.normal_to_test("+"))
124
+ assert_equal("test_tilde", @tester.normal_to_test("~"))
125
+ end
126
+
127
+ def test_normal_to_test_overlap
128
+ self.util_simple_setup
129
+ assert_equal("test_equals2", @tester.normal_to_test("=="))
130
+ assert_equal("test_equals3", @tester.normal_to_test("==="))
131
+ assert_equal("test_ge", @tester.normal_to_test(">="))
132
+ assert_equal("test_gt", @tester.normal_to_test(">"))
133
+ assert_equal("test_gt2", @tester.normal_to_test(">>"))
134
+ assert_equal("test_index", @tester.normal_to_test("[]"))
135
+ assert_equal("test_index_equals", @tester.normal_to_test("[]="))
136
+ assert_equal("test_lt", @tester.normal_to_test("<"))
137
+ assert_equal("test_lt2", @tester.normal_to_test("<\<"))
138
+ assert_equal("test_lte", @tester.normal_to_test("<="))
139
+ assert_equal("test_method", @tester.normal_to_test("method"))
140
+ assert_equal("test_method_equals", @tester.normal_to_test("method="))
141
+ assert_equal("test_spaceship", @tester.normal_to_test("<=>"))
142
+ assert_equal("test_times", @tester.normal_to_test("*"))
143
+ assert_equal("test_times2", @tester.normal_to_test("**"))
144
+ assert_equal("test_unary_minus", @tester.normal_to_test("-@"))
145
+ assert_equal("test_unary_plus", @tester.normal_to_test("+@"))
146
+ assert_equal("test_class_index", @tester.normal_to_test("self.[]"))
147
+ end
148
+
149
+ def test_test_to_normal
150
+ self.util_simple_setup
151
+ assert_equal("method1!",
152
+ @tester.test_to_normal("test_method1_bang", "Something"))
153
+ assert_equal("method1",
154
+ @tester.test_to_normal("test_method1", "Something"))
155
+ assert_equal("method1=",
156
+ @tester.test_to_normal("test_method1_equals", "Something"))
157
+ assert_equal("method1?",
158
+ @tester.test_to_normal("test_method1_eh", "Something"))
159
+ end
160
+
161
+ def test_test_to_normal_cls
162
+ self.util_simple_setup
163
+ assert_equal("self.method1",
164
+ @tester.test_to_normal("test_class_method1"))
165
+ assert_equal("self.method1!",
166
+ @tester.test_to_normal("test_class_method1_bang"))
167
+ assert_equal("self.method1?",
168
+ @tester.test_to_normal("test_class_method1_eh"))
169
+ assert_equal("self.method1=",
170
+ @tester.test_to_normal("test_class_method1_equals"))
171
+ assert_equal("self.[]",
172
+ @tester.test_to_normal("test_class_index"))
173
+ end
174
+
175
+ def test_test_to_normal_extended
176
+ self.util_simple_setup
177
+ assert_equal("equal?",
178
+ @tester.test_to_normal("test_equal_eh_extension",
179
+ "Something"))
180
+ assert_equal("equal?",
181
+ @tester.test_to_normal("test_equal_eh_extension_again",
182
+ "Something"))
183
+ assert_equal("method1",
184
+ @tester.test_to_normal("test_method1_extension",
185
+ "Something"))
186
+ assert_equal("method1",
187
+ @tester.test_to_normal("test_method1_extension_again",
188
+ "Something"))
189
+ end
190
+
191
+ def test_test_to_normal_mapped
192
+ self.util_simple_setup
193
+ assert_equal("*", @tester.test_to_normal("test_times"))
194
+ assert_equal("*", @tester.test_to_normal("test_times_ext"))
195
+ assert_equal("==", @tester.test_to_normal("test_equals2"))
196
+ assert_equal("==", @tester.test_to_normal("test_equals2_ext"))
197
+ assert_equal("===", @tester.test_to_normal("test_equals3"))
198
+ assert_equal("===", @tester.test_to_normal("test_equals3_ext"))
199
+ assert_equal("[]", @tester.test_to_normal("test_index"))
200
+ assert_equal("[]", @tester.test_to_normal("test_index_ext"))
201
+ assert_equal("[]=", @tester.test_to_normal("test_index_equals"))
202
+ assert_equal("[]=", @tester.test_to_normal("test_index_equals_ext"))
203
+ end
204
+
205
+ def test_test_to_normal_operators
206
+ self.util_simple_setup
207
+ assert_equal("&", @tester.test_to_normal("test_and"))
208
+ assert_equal("!", @tester.test_to_normal("test_bang"))
209
+ assert_equal("^", @tester.test_to_normal("test_carat"))
210
+ assert_equal("/", @tester.test_to_normal("test_div"))
211
+ assert_equal("=~", @tester.test_to_normal("test_equalstilde"))
212
+ assert_equal("-", @tester.test_to_normal("test_minus"))
213
+ assert_equal("|", @tester.test_to_normal("test_or"))
214
+ assert_equal("%", @tester.test_to_normal("test_percent"))
215
+ assert_equal("+", @tester.test_to_normal("test_plus"))
216
+ assert_equal("~", @tester.test_to_normal("test_tilde"))
217
+ end
218
+
219
+ def test_test_to_normal_overlap
220
+ self.util_simple_setup
221
+ assert_equal("==", @tester.test_to_normal("test_equals2"))
222
+ assert_equal("===", @tester.test_to_normal("test_equals3"))
223
+ assert_equal(">=", @tester.test_to_normal("test_ge"))
224
+ assert_equal(">", @tester.test_to_normal("test_gt"))
225
+ assert_equal(">>", @tester.test_to_normal("test_gt2"))
226
+ assert_equal("[]", @tester.test_to_normal("test_index"))
227
+ assert_equal("[]=", @tester.test_to_normal("test_index_equals"))
228
+ assert_equal("<", @tester.test_to_normal("test_lt"))
229
+ assert_equal("<\<", @tester.test_to_normal("test_lt2"))
230
+ assert_equal("<=", @tester.test_to_normal("test_lte"))
231
+ assert_equal("<=>", @tester.test_to_normal("test_spaceship"))
232
+ assert_equal("*", @tester.test_to_normal("test_times"))
233
+ assert_equal("**", @tester.test_to_normal("test_times2"))
234
+ assert_equal("-@", @tester.test_to_normal("test_unary_minus"))
235
+ assert_equal("+@", @tester.test_to_normal("test_unary_plus"))
236
+ end
237
+
238
+ def test_to_normal_subset
239
+ self.util_simple_setup
240
+ assert_equal("get_foo", @tester.test_to_normal("test_get_foo"))
241
+ end
242
+ end
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: SlimZenTest
3
+ version: !ruby/object:Gem::Version
4
+ hash: 35
5
+ prerelease:
6
+ segments:
7
+ - 4
8
+ - 6
9
+ - 2
10
+ version: 4.6.2
11
+ platform: ruby
12
+ authors:
13
+ - Ryan Davis
14
+ - Eric Hodel
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2011-09-06 00:00:00 -07:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: hoe
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ hash: 27
31
+ segments:
32
+ - 2
33
+ - 12
34
+ version: "2.12"
35
+ type: :development
36
+ version_requirements: *id001
37
+ description: |-
38
+ ZenTest provides 4 different tools: zentest, unit_diff, autotest, and
39
+ multiruby.
40
+
41
+ ZenTest scans your target and unit-test code and writes your missing
42
+ code based on simple naming rules, enabling XP at a much quicker
43
+ pace. ZenTest only works with Ruby and Test::Unit. Nobody uses this
44
+ tool anymore but it is the package namesake, so it stays.
45
+
46
+ unit_diff is a command-line filter to diff expected results from
47
+ actual results and allow you to quickly see exactly what is wrong.
48
+ Do note that minitest 2.2+ provides an enhanced assert_equal obviating
49
+ the need for unit_diff
50
+
51
+ autotest is a continous testing facility meant to be used during
52
+ development. As soon as you save a file, autotest will run the
53
+ corresponding dependent tests.
54
+
55
+ multiruby runs anything you want on multiple versions of ruby. Great
56
+ for compatibility checking! Use multiruby_setup to manage your
57
+ installed versions.
58
+ email:
59
+ - ryand-ruby@zenspider.com
60
+ - drbrain@segment7.net
61
+ executables:
62
+ - autotest
63
+ - multigem
64
+ - multiruby
65
+ - multiruby_setup
66
+ - unit_diff
67
+ - zentest
68
+ extensions: []
69
+
70
+ extra_rdoc_files:
71
+ - History.txt
72
+ - Manifest.txt
73
+ - README.txt
74
+ - articles/how_to_use_zentest.txt
75
+ - example.txt
76
+ files:
77
+ - .autotest
78
+ - History.txt
79
+ - Manifest.txt
80
+ - README.txt
81
+ - Rakefile
82
+ - articles/Article.css
83
+ - articles/getting_started_with_autotest.html
84
+ - articles/how_to_use_zentest.txt
85
+ - bin/autotest
86
+ - bin/multigem
87
+ - bin/multiruby
88
+ - bin/multiruby_setup
89
+ - bin/unit_diff
90
+ - bin/zentest
91
+ - example.txt
92
+ - example1.rb
93
+ - example2.rb
94
+ - example_dot_autotest.rb
95
+ - lib/autotest.rb
96
+ - lib/autotest/autoupdate.rb
97
+ - lib/autotest/bundler.rb
98
+ - lib/autotest/isolate.rb
99
+ - lib/autotest/once.rb
100
+ - lib/autotest/preload.rb
101
+ - lib/autotest/rcov.rb
102
+ - lib/autotest/restart.rb
103
+ - lib/autotest/timestamp.rb
104
+ - lib/focus.rb
105
+ - lib/functional_test_matrix.rb
106
+ - lib/multiruby.rb
107
+ - lib/unit_diff.rb
108
+ - lib/zentest.rb
109
+ - lib/zentest_mapping.rb
110
+ - test/test_autotest.rb
111
+ - test/test_focus.rb
112
+ - test/test_unit_diff.rb
113
+ - test/test_zentest.rb
114
+ - test/test_zentest_mapping.rb
115
+ - .gemtest
116
+ has_rdoc: true
117
+ homepage: https://github.com/seattlerb/zentest
118
+ licenses: []
119
+
120
+ post_install_message:
121
+ rdoc_options:
122
+ - --main
123
+ - README.txt
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ hash: 3
132
+ segments:
133
+ - 0
134
+ version: "0"
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ hash: 3
141
+ segments:
142
+ - 0
143
+ version: "0"
144
+ requirements: []
145
+
146
+ rubyforge_project: slimzentest
147
+ rubygems_version: 1.3.9.2
148
+ signing_key:
149
+ specification_version: 3
150
+ summary: "ZenTest provides 4 different tools: zentest, unit_diff, autotest, and multiruby"
151
+ test_files:
152
+ - test/test_autotest.rb
153
+ - test/test_focus.rb
154
+ - test/test_unit_diff.rb
155
+ - test/test_zentest.rb
156
+ - test/test_zentest_mapping.rb