transpec 0.2.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +10 -0
- data/README.md +111 -56
- data/README.md.erb +117 -62
- data/lib/transpec/ast/node.rb +41 -0
- data/lib/transpec/base_rewriter.rb +55 -0
- data/lib/transpec/cli.rb +43 -153
- data/lib/transpec/configuration.rb +13 -9
- data/lib/transpec/{rewriter.rb → converter.rb} +44 -71
- data/lib/transpec/dynamic_analyzer/rewriter.rb +94 -0
- data/lib/transpec/dynamic_analyzer/runtime_data.rb +27 -0
- data/lib/transpec/dynamic_analyzer.rb +166 -0
- data/lib/transpec/file_finder.rb +53 -0
- data/lib/transpec/option_parser.rb +166 -0
- data/lib/transpec/{context.rb → static_context_inspector.rb} +2 -2
- data/lib/transpec/syntax/be_close.rb +7 -9
- data/lib/transpec/syntax/double.rb +6 -10
- data/lib/transpec/syntax/expect.rb +35 -0
- data/lib/transpec/syntax/have.rb +195 -0
- data/lib/transpec/syntax/method_stub.rb +22 -27
- data/lib/transpec/syntax/mixin/allow_no_message.rb +73 -0
- data/lib/transpec/syntax/mixin/any_instance.rb +22 -0
- data/lib/transpec/syntax/mixin/expectizable.rb +26 -0
- data/lib/transpec/syntax/mixin/have_matcher.rb +23 -0
- data/lib/transpec/syntax/mixin/monkey_patch.rb +37 -0
- data/lib/transpec/syntax/mixin/send.rb +109 -0
- data/lib/transpec/syntax/{matcher.rb → operator_matcher.rb} +27 -14
- data/lib/transpec/syntax/raise_error.rb +6 -10
- data/lib/transpec/syntax/rspec_configure.rb +29 -28
- data/lib/transpec/syntax/should.rb +45 -15
- data/lib/transpec/syntax/should_receive.rb +44 -16
- data/lib/transpec/syntax.rb +29 -21
- data/lib/transpec/util.rb +12 -2
- data/lib/transpec/version.rb +3 -3
- data/spec/spec_helper.rb +8 -6
- data/spec/support/cache_helper.rb +50 -0
- data/spec/support/shared_context.rb +49 -1
- data/spec/transpec/ast/node_spec.rb +65 -0
- data/spec/transpec/cli_spec.rb +33 -242
- data/spec/transpec/commit_message_spec.rb +2 -2
- data/spec/transpec/configuration_spec.rb +12 -8
- data/spec/transpec/{rewriter_spec.rb → converter_spec.rb} +198 -148
- data/spec/transpec/dynamic_analyzer/rewriter_spec.rb +183 -0
- data/spec/transpec/dynamic_analyzer_spec.rb +164 -0
- data/spec/transpec/file_finder_spec.rb +118 -0
- data/spec/transpec/option_parser_spec.rb +185 -0
- data/spec/transpec/{context_spec.rb → static_context_inspector_spec.rb} +27 -12
- data/spec/transpec/syntax/be_close_spec.rb +8 -4
- data/spec/transpec/syntax/double_spec.rb +105 -12
- data/spec/transpec/syntax/expect_spec.rb +83 -0
- data/spec/transpec/syntax/have_spec.rb +599 -0
- data/spec/transpec/syntax/method_stub_spec.rb +276 -115
- data/spec/transpec/syntax/{matcher_spec.rb → operator_matcher_spec.rb} +277 -98
- data/spec/transpec/syntax/raise_error_spec.rb +92 -46
- data/spec/transpec/syntax/should_receive_spec.rb +298 -92
- data/spec/transpec/syntax/should_spec.rb +230 -44
- data/spec/transpec/util_spec.rb +2 -9
- data/tasks/lib/transpec_demo.rb +1 -1
- data/tasks/lib/transpec_test.rb +5 -7
- data/tasks/test.rake +5 -1
- data/transpec.gemspec +1 -1
- metadata +46 -22
- data/lib/transpec/syntax/able_to_allow_no_message.rb +0 -73
- data/lib/transpec/syntax/able_to_target_any_instance.rb +0 -24
- data/lib/transpec/syntax/expectizable.rb +0 -27
- data/lib/transpec/syntax/send_node_syntax.rb +0 -57
@@ -28,8 +28,10 @@ module Transpec
|
|
28
28
|
context 'when it is `lambda { }.should raise_error` form' do
|
29
29
|
let(:source) do
|
30
30
|
<<-END
|
31
|
-
|
32
|
-
|
31
|
+
describe 'example' do
|
32
|
+
it 'raises error' do
|
33
|
+
lambda { do_something }.should raise_error
|
34
|
+
end
|
33
35
|
end
|
34
36
|
END
|
35
37
|
end
|
@@ -40,8 +42,10 @@ module Transpec
|
|
40
42
|
context 'when it is `expect { }.to raise_error` form' do
|
41
43
|
let(:source) do
|
42
44
|
<<-END
|
43
|
-
|
44
|
-
|
45
|
+
describe 'example' do
|
46
|
+
it 'raises error' do
|
47
|
+
expect { do_something }.to raise_error
|
48
|
+
end
|
45
49
|
end
|
46
50
|
END
|
47
51
|
end
|
@@ -52,8 +56,10 @@ module Transpec
|
|
52
56
|
context 'when it is `lambda { }.should raise_error { |error| ... }` form' do
|
53
57
|
let(:source) do
|
54
58
|
<<-END
|
55
|
-
|
56
|
-
|
59
|
+
describe 'example' do
|
60
|
+
it 'raises error' do
|
61
|
+
lambda { do_something }.should raise_error { |error| do_anything }
|
62
|
+
end
|
57
63
|
end
|
58
64
|
END
|
59
65
|
end
|
@@ -64,8 +70,10 @@ module Transpec
|
|
64
70
|
context 'when it is `expect { }.to raise_error { |error| ... }` form' do
|
65
71
|
let(:source) do
|
66
72
|
<<-END
|
67
|
-
|
68
|
-
|
73
|
+
describe 'example' do
|
74
|
+
it 'raises error' do
|
75
|
+
expect { do_something }.to raise_error { |error| do_anything }
|
76
|
+
end
|
69
77
|
end
|
70
78
|
END
|
71
79
|
end
|
@@ -76,8 +84,10 @@ module Transpec
|
|
76
84
|
context 'when it is `lambda { }.should_not raise_error` form' do
|
77
85
|
let(:source) do
|
78
86
|
<<-END
|
79
|
-
|
80
|
-
|
87
|
+
describe 'example' do
|
88
|
+
it 'does not raise error' do
|
89
|
+
lambda { do_something }.should_not raise_error
|
90
|
+
end
|
81
91
|
end
|
82
92
|
END
|
83
93
|
end
|
@@ -88,8 +98,10 @@ module Transpec
|
|
88
98
|
context 'when it is `expect { }.not_to raise_error` form' do
|
89
99
|
let(:source) do
|
90
100
|
<<-END
|
91
|
-
|
92
|
-
|
101
|
+
describe 'example' do
|
102
|
+
it 'does not raise error' do
|
103
|
+
expect { do_something }.not_to raise_error
|
104
|
+
end
|
93
105
|
end
|
94
106
|
END
|
95
107
|
end
|
@@ -100,8 +112,10 @@ module Transpec
|
|
100
112
|
context 'when it is `expect { }.to_not raise_error` form' do
|
101
113
|
let(:source) do
|
102
114
|
<<-END
|
103
|
-
|
104
|
-
|
115
|
+
describe 'example' do
|
116
|
+
it 'does not raise error' do
|
117
|
+
expect { do_something }.to_not raise_error
|
118
|
+
end
|
105
119
|
end
|
106
120
|
END
|
107
121
|
end
|
@@ -118,8 +132,10 @@ module Transpec
|
|
118
132
|
context 'when it is `lambda { }.should raise_error(SpecificErrorClass)` form' do
|
119
133
|
let(:source) do
|
120
134
|
<<-END
|
121
|
-
|
122
|
-
|
135
|
+
describe 'example' do
|
136
|
+
it 'raises SpecificErrorClass' do
|
137
|
+
lambda { do_something }.should raise_error(SpecificErrorClass)
|
138
|
+
end
|
123
139
|
end
|
124
140
|
END
|
125
141
|
end
|
@@ -136,8 +152,10 @@ module Transpec
|
|
136
152
|
context 'when it is `expect { }.to raise_error(SpecificErrorClass)` form' do
|
137
153
|
let(:source) do
|
138
154
|
<<-END
|
139
|
-
|
140
|
-
|
155
|
+
describe 'example' do
|
156
|
+
it 'raises SpecificErrorClass' do
|
157
|
+
expect { do_something }.to raise_error(SpecificErrorClass)
|
158
|
+
end
|
141
159
|
end
|
142
160
|
END
|
143
161
|
end
|
@@ -154,8 +172,10 @@ module Transpec
|
|
154
172
|
context 'when it is `lambda { }.should raise_error(SpecificErrorClass) { |error| ... }` form' do
|
155
173
|
let(:source) do
|
156
174
|
<<-END
|
157
|
-
|
158
|
-
|
175
|
+
describe 'example' do
|
176
|
+
it 'raises SpecificErrorClass' do
|
177
|
+
lambda { do_something }.should raise_error(SpecificErrorClass) { |error| do_anything }
|
178
|
+
end
|
159
179
|
end
|
160
180
|
END
|
161
181
|
end
|
@@ -172,8 +192,10 @@ module Transpec
|
|
172
192
|
context 'when it is `expect { }.to raise_error(SpecificErrorClass) { |error| ... }` form' do
|
173
193
|
let(:source) do
|
174
194
|
<<-END
|
175
|
-
|
176
|
-
|
195
|
+
describe 'example' do
|
196
|
+
it 'raises SpecificErrorClass' do
|
197
|
+
expect { do_something }.to raise_error(SpecificErrorClass) { |error| do_anything }
|
198
|
+
end
|
177
199
|
end
|
178
200
|
END
|
179
201
|
end
|
@@ -190,16 +212,20 @@ module Transpec
|
|
190
212
|
context 'when it is `lambda { }.should_not raise_error(SpecificErrorClass)` form' do
|
191
213
|
let(:source) do
|
192
214
|
<<-END
|
193
|
-
|
194
|
-
|
215
|
+
describe 'example' do
|
216
|
+
it 'does not raise error' do
|
217
|
+
lambda { do_something }.should_not raise_error(SpecificErrorClass)
|
218
|
+
end
|
195
219
|
end
|
196
220
|
END
|
197
221
|
end
|
198
222
|
|
199
223
|
let(:expected_source) do
|
200
224
|
<<-END
|
201
|
-
|
202
|
-
|
225
|
+
describe 'example' do
|
226
|
+
it 'does not raise error' do
|
227
|
+
lambda { do_something }.should_not raise_error
|
228
|
+
end
|
203
229
|
end
|
204
230
|
END
|
205
231
|
end
|
@@ -218,16 +244,20 @@ module Transpec
|
|
218
244
|
context 'when it is `expect { }.not_to raise_error(SpecificErrorClass)` form' do
|
219
245
|
let(:source) do
|
220
246
|
<<-END
|
221
|
-
|
222
|
-
|
247
|
+
describe 'example' do
|
248
|
+
it 'does not raise error' do
|
249
|
+
expect { do_something }.not_to raise_error(SpecificErrorClass)
|
250
|
+
end
|
223
251
|
end
|
224
252
|
END
|
225
253
|
end
|
226
254
|
|
227
255
|
let(:expected_source) do
|
228
256
|
<<-END
|
229
|
-
|
230
|
-
|
257
|
+
describe 'example' do
|
258
|
+
it 'does not raise error' do
|
259
|
+
expect { do_something }.not_to raise_error
|
260
|
+
end
|
231
261
|
end
|
232
262
|
END
|
233
263
|
end
|
@@ -240,16 +270,20 @@ module Transpec
|
|
240
270
|
context 'when it is `expect { }.to_not raise_error(SpecificErrorClass)` form' do
|
241
271
|
let(:source) do
|
242
272
|
<<-END
|
243
|
-
|
244
|
-
|
273
|
+
describe 'example' do
|
274
|
+
it 'does not raise error' do
|
275
|
+
expect { do_something }.to_not raise_error(SpecificErrorClass)
|
276
|
+
end
|
245
277
|
end
|
246
278
|
END
|
247
279
|
end
|
248
280
|
|
249
281
|
let(:expected_source) do
|
250
282
|
<<-END
|
251
|
-
|
252
|
-
|
283
|
+
describe 'example' do
|
284
|
+
it 'does not raise error' do
|
285
|
+
expect { do_something }.to_not raise_error
|
286
|
+
end
|
253
287
|
end
|
254
288
|
END
|
255
289
|
end
|
@@ -268,16 +302,20 @@ module Transpec
|
|
268
302
|
context 'when it is `expect { }.not_to raise_error SpecificErrorClass` form' do
|
269
303
|
let(:source) do
|
270
304
|
<<-END
|
271
|
-
|
272
|
-
|
305
|
+
describe 'example' do
|
306
|
+
it 'does not raise error' do
|
307
|
+
expect { do_something }.not_to raise_error SpecificErrorClass
|
308
|
+
end
|
273
309
|
end
|
274
310
|
END
|
275
311
|
end
|
276
312
|
|
277
313
|
let(:expected_source) do
|
278
314
|
<<-END
|
279
|
-
|
280
|
-
|
315
|
+
describe 'example' do
|
316
|
+
it 'does not raise error' do
|
317
|
+
expect { do_something }.not_to raise_error
|
318
|
+
end
|
281
319
|
end
|
282
320
|
END
|
283
321
|
end
|
@@ -296,16 +334,20 @@ module Transpec
|
|
296
334
|
context 'when it is `expect { }.not_to raise_error(SpecificErrorClass, message)` form' do
|
297
335
|
let(:source) do
|
298
336
|
<<-END
|
299
|
-
|
300
|
-
|
337
|
+
describe 'example' do
|
338
|
+
it 'does not raise error' do
|
339
|
+
expect { do_something }.not_to raise_error(SpecificErrorClass, message)
|
340
|
+
end
|
301
341
|
end
|
302
342
|
END
|
303
343
|
end
|
304
344
|
|
305
345
|
let(:expected_source) do
|
306
346
|
<<-END
|
307
|
-
|
308
|
-
|
347
|
+
describe 'example' do
|
348
|
+
it 'does not raise error' do
|
349
|
+
expect { do_something }.not_to raise_error
|
350
|
+
end
|
309
351
|
end
|
310
352
|
END
|
311
353
|
end
|
@@ -324,16 +366,20 @@ module Transpec
|
|
324
366
|
context 'when it is `expect { }.not_to raise_error(message)` form' do
|
325
367
|
let(:source) do
|
326
368
|
<<-END
|
327
|
-
|
328
|
-
|
369
|
+
describe 'example' do
|
370
|
+
it 'does not raise error' do
|
371
|
+
expect { do_something }.not_to raise_error(message)
|
372
|
+
end
|
329
373
|
end
|
330
374
|
END
|
331
375
|
end
|
332
376
|
|
333
377
|
let(:expected_source) do
|
334
378
|
<<-END
|
335
|
-
|
336
|
-
|
379
|
+
describe 'example' do
|
380
|
+
it 'does not raise error' do
|
381
|
+
expect { do_something }.not_to raise_error
|
382
|
+
end
|
337
383
|
end
|
338
384
|
END
|
339
385
|
end
|