transpec 3.0.0 → 3.0.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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/CHANGELOG.md +4 -0
  4. data/lib/transpec/version.rb +1 -1
  5. data/transpec.gemspec +4 -3
  6. metadata +3 -97
  7. data/spec/.rubocop.yml +0 -23
  8. data/spec/integration/configuration_modification_spec.rb +0 -186
  9. data/spec/integration/conversion_spec.rb +0 -145
  10. data/spec/spec_helper.rb +0 -52
  11. data/spec/support/cache_helper.rb +0 -62
  12. data/spec/support/file_helper.rb +0 -25
  13. data/spec/support/shared_context.rb +0 -84
  14. data/spec/transpec/cli_spec.rb +0 -341
  15. data/spec/transpec/commit_message_spec.rb +0 -81
  16. data/spec/transpec/config_spec.rb +0 -99
  17. data/spec/transpec/converter_spec.rb +0 -1374
  18. data/spec/transpec/directory_cloner_spec.rb +0 -74
  19. data/spec/transpec/dynamic_analyzer/rewriter_spec.rb +0 -143
  20. data/spec/transpec/dynamic_analyzer_spec.rb +0 -329
  21. data/spec/transpec/git_spec.rb +0 -151
  22. data/spec/transpec/option_parser_spec.rb +0 -275
  23. data/spec/transpec/processed_source_spec.rb +0 -93
  24. data/spec/transpec/project_spec.rb +0 -194
  25. data/spec/transpec/record_spec.rb +0 -128
  26. data/spec/transpec/report_spec.rb +0 -126
  27. data/spec/transpec/rspec_version_spec.rb +0 -129
  28. data/spec/transpec/spec_file_finder_spec.rb +0 -118
  29. data/spec/transpec/spec_suite_spec.rb +0 -108
  30. data/spec/transpec/static_context_inspector_spec.rb +0 -713
  31. data/spec/transpec/syntax/allow_spec.rb +0 -122
  32. data/spec/transpec/syntax/be_boolean_spec.rb +0 -176
  33. data/spec/transpec/syntax/be_close_spec.rb +0 -51
  34. data/spec/transpec/syntax/current_example_spec.rb +0 -319
  35. data/spec/transpec/syntax/double_spec.rb +0 -175
  36. data/spec/transpec/syntax/example_group_spec.rb +0 -716
  37. data/spec/transpec/syntax/example_spec.rb +0 -301
  38. data/spec/transpec/syntax/expect_spec.rb +0 -313
  39. data/spec/transpec/syntax/have_spec.rb +0 -1276
  40. data/spec/transpec/syntax/hook_spec.rb +0 -215
  41. data/spec/transpec/syntax/its_spec.rb +0 -448
  42. data/spec/transpec/syntax/matcher_definition_spec.rb +0 -59
  43. data/spec/transpec/syntax/method_stub_spec.rb +0 -1301
  44. data/spec/transpec/syntax/oneliner_should_spec.rb +0 -628
  45. data/spec/transpec/syntax/operator_spec.rb +0 -871
  46. data/spec/transpec/syntax/pending_spec.rb +0 -415
  47. data/spec/transpec/syntax/raise_error_spec.rb +0 -354
  48. data/spec/transpec/syntax/receive_spec.rb +0 -499
  49. data/spec/transpec/syntax/rspec_configure_spec.rb +0 -870
  50. data/spec/transpec/syntax/should_receive_spec.rb +0 -1108
  51. data/spec/transpec/syntax/should_spec.rb +0 -497
  52. data/spec/transpec/util_spec.rb +0 -115
  53. data/spec/transpec_spec.rb +0 -22
@@ -1,122 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
- require 'transpec/syntax/allow'
5
-
6
- module Transpec
7
- class Syntax
8
- describe Allow do
9
- include_context 'parsed objects'
10
- include_context 'syntax object', Allow, :allow_object
11
-
12
- describe '#subject_node' do
13
- let(:source) do
14
- <<-END
15
- describe 'example' do
16
- it 'is empty' do
17
- allow(subject).to be_empty
18
- end
19
- end
20
- END
21
- end
22
-
23
- it 'returns subject node' do
24
- method_name = allow_object.subject_node.children[1]
25
- method_name.should == :subject
26
- end
27
- end
28
-
29
- describe '#matcher_node' do
30
- context 'when the matcher is taking a block' do
31
- let(:source) do
32
- <<-END
33
- describe 'example' do
34
- it 'is empty' do
35
- allow(subject).to receive(:foo) { }
36
- end
37
- end
38
- END
39
- end
40
-
41
- it 'returns send node of the matcher' do
42
- method_name = allow_object.matcher_node.children[1]
43
- method_name.should == :receive
44
- end
45
- end
46
-
47
- context 'when the matcher is not taking a block' do
48
- let(:source) do
49
- <<-END
50
- describe 'example' do
51
- it 'is empty' do
52
- allow(subject).to be_empty
53
- end
54
- end
55
- END
56
- end
57
-
58
- it 'returns send node of the matcher' do
59
- method_name = allow_object.matcher_node.children[1]
60
- method_name.should == :be_empty
61
- end
62
- end
63
- end
64
-
65
- describe '#receive_matcher' do
66
- subject { allow_object.receive_matcher }
67
-
68
- let(:source) do
69
- <<-END
70
- describe 'example' do
71
- it 'receives :foo' do
72
- allow(subject).to receive(:foo)
73
- end
74
- end
75
- END
76
- end
77
-
78
- it 'returns an instance of Receive' do
79
- should be_an(Receive)
80
- end
81
- end
82
-
83
- describe '#block_node' do
84
- subject { allow_object.block_node }
85
-
86
- context 'when the #to is taking a block' do
87
- let(:source) do
88
- <<-END
89
- describe 'example' do
90
- it 'receives :foo' do
91
- allow(subject).to receive(:foo) do |arg|
92
- end
93
- end
94
- end
95
- END
96
- end
97
-
98
- it 'returns the block node' do
99
- should be_block_type
100
- end
101
- end
102
-
103
- context 'when the #to is not taking a block' do
104
- let(:source) do
105
- <<-END
106
- describe 'example' do
107
- it 'receives :foo' do
108
- allow(subject).to receive(:foo) { |arg|
109
- }
110
- end
111
- end
112
- END
113
- end
114
-
115
- it 'returns nil' do
116
- should be_nil
117
- end
118
- end
119
- end
120
- end
121
- end
122
- end
@@ -1,176 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
- require 'transpec/syntax/be_boolean'
5
-
6
- module Transpec
7
- class Syntax
8
- describe BeBoolean do
9
- include_context 'parsed objects'
10
- include_context 'syntax object', BeBoolean, :be_boolean_object
11
-
12
- let(:record) { be_boolean_object.report.records.last }
13
-
14
- describe '#convert_to_conditional_matcher!' do
15
- before do
16
- be_boolean_object.convert_to_conditional_matcher!(arg)
17
- end
18
-
19
- let(:arg) { 'be_falsey' }
20
-
21
- context 'with expression `be_true`' do
22
- let(:source) do
23
- <<-END
24
- describe 'example' do
25
- it 'is truthy' do
26
- 1.should be_true
27
- end
28
- end
29
- END
30
- end
31
-
32
- let(:expected_source) do
33
- <<-END
34
- describe 'example' do
35
- it 'is truthy' do
36
- 1.should be_truthy
37
- end
38
- end
39
- END
40
- end
41
-
42
- it 'converts to `be_truthy`' do
43
- rewritten_source.should == expected_source
44
- end
45
-
46
- it 'adds record `be_true` -> `be_truthy`' do
47
- record.old_syntax.should == 'be_true'
48
- record.new_syntax.should == 'be_truthy'
49
- end
50
- end
51
-
52
- context 'with expression `be_false`' do
53
- let(:source) do
54
- <<-END
55
- describe 'example' do
56
- it 'is falsey' do
57
- nil.should be_false
58
- end
59
- end
60
- END
61
- end
62
-
63
- let(:expected_source) do
64
- <<-END
65
- describe 'example' do
66
- it 'is falsey' do
67
- nil.should be_falsey
68
- end
69
- end
70
- END
71
- end
72
-
73
- it 'converts to `be_falsey`' do
74
- rewritten_source.should == expected_source
75
- end
76
-
77
- it 'adds record `be_false` -> `be_falsey`' do
78
- record.old_syntax.should == 'be_false'
79
- record.new_syntax.should == 'be_falsey'
80
- end
81
-
82
- context 'and "be_falsy" is passed' do
83
- let(:arg) { 'be_falsy' }
84
-
85
- let(:expected_source) do
86
- <<-END
87
- describe 'example' do
88
- it 'is falsey' do
89
- nil.should be_falsy
90
- end
91
- end
92
- END
93
- end
94
-
95
- it 'converts to `be_falsy`' do
96
- rewritten_source.should == expected_source
97
- end
98
-
99
- it 'adds record `be_false` -> `be_falsy`' do
100
- record.old_syntax.should == 'be_false'
101
- record.new_syntax.should == 'be_falsy'
102
- end
103
- end
104
- end
105
- end
106
-
107
- describe '#convert_to_exact_matcher!' do
108
- before do
109
- be_boolean_object.convert_to_exact_matcher!
110
- end
111
-
112
- context 'with expression `be_true`' do
113
- let(:source) do
114
- <<-END
115
- describe 'example' do
116
- it 'is true' do
117
- true.should be_true
118
- end
119
- end
120
- END
121
- end
122
-
123
- let(:expected_source) do
124
- <<-END
125
- describe 'example' do
126
- it 'is true' do
127
- true.should be true
128
- end
129
- end
130
- END
131
- end
132
-
133
- it 'converts to `be true`' do
134
- rewritten_source.should == expected_source
135
- end
136
-
137
- it 'adds record `be_true` -> `be true`' do
138
- record.old_syntax.should == 'be_true'
139
- record.new_syntax.should == 'be true'
140
- end
141
- end
142
-
143
- context 'with expression `be_false`' do
144
- let(:source) do
145
- <<-END
146
- describe 'example' do
147
- it 'is false' do
148
- false.should be_false
149
- end
150
- end
151
- END
152
- end
153
-
154
- let(:expected_source) do
155
- <<-END
156
- describe 'example' do
157
- it 'is false' do
158
- false.should be false
159
- end
160
- end
161
- END
162
- end
163
-
164
- it 'converts to `be false`' do
165
- rewritten_source.should == expected_source
166
- end
167
-
168
- it 'adds record `be_false` -> `be false`' do
169
- record.old_syntax.should == 'be_false'
170
- record.new_syntax.should == 'be false'
171
- end
172
- end
173
- end
174
- end
175
- end
176
- end
@@ -1,51 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
- require 'transpec/syntax/be_close'
5
-
6
- module Transpec
7
- class Syntax
8
- describe BeClose do
9
- include_context 'parsed objects'
10
- include_context 'syntax object', BeClose, :be_close_object
11
-
12
- describe '#convert_to_be_within!' do
13
- before do
14
- be_close_object.convert_to_be_within!
15
- end
16
-
17
- context 'with expression `be_close(expected, delta)`' do
18
- let(:source) do
19
- <<-END
20
- describe 'example' do
21
- it 'is close to 0.333' do
22
- (1.0 / 3.0).should be_close(0.333, 0.001)
23
- end
24
- end
25
- END
26
- end
27
-
28
- let(:expected_source) do
29
- <<-END
30
- describe 'example' do
31
- it 'is close to 0.333' do
32
- (1.0 / 3.0).should be_within(0.001).of(0.333)
33
- end
34
- end
35
- END
36
- end
37
-
38
- it 'converts to `be_within(delta).of(expected)` form' do
39
- rewritten_source.should == expected_source
40
- end
41
-
42
- it 'adds record `be_close(expected, delta)` -> `be_within(delta).of(expected)`' do
43
- record = be_close_object.report.records.first
44
- record.old_syntax.should == 'be_close(expected, delta)'
45
- record.new_syntax.should == 'be_within(delta).of(expected)'
46
- end
47
- end
48
- end
49
- end
50
- end
51
- end
@@ -1,319 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
- require 'transpec/syntax/current_example'
5
-
6
- module Transpec
7
- class Syntax
8
- describe CurrentExample do
9
- include_context 'parsed objects'
10
- include_context 'syntax object', CurrentExample, :current_example_object
11
-
12
- let(:record) { current_example_object.report.records.last }
13
-
14
- describe '#conversion_target?' do
15
- let(:target_node) do
16
- ast.each_node(:send).find do |send_node|
17
- method_name = send_node.children[1]
18
- method_name == :example
19
- end
20
- end
21
-
22
- let(:current_example_object) do
23
- CurrentExample.new(target_node, runtime_data)
24
- end
25
-
26
- subject { current_example_object.conversion_target? }
27
-
28
- context 'with #example node that returns current example object' do
29
- let(:source) do
30
- <<-END
31
- describe 'example' do
32
- after do
33
- do_something if example.metadata[:foo]
34
- end
35
- end
36
- END
37
- end
38
-
39
- it { should be_true }
40
- end
41
-
42
- context 'when #example node that defines a spec example is passed' do
43
- let(:source) do
44
- <<-END
45
- describe 'example' do
46
- example 'it does something' do
47
- do_something
48
- end
49
- end
50
- END
51
- end
52
-
53
- it { should be_false }
54
- end
55
-
56
- context 'when #example node defined with #let by user is passed' do
57
- let(:source) do
58
- <<-END
59
- describe 'example' do
60
- let(:example) { 'This is not current example object' }
61
-
62
- it 'does something' do
63
- example
64
- end
65
- end
66
- END
67
- end
68
-
69
- it 'unfortunately returns true ' \
70
- "since it's impossible to differentiate them without runtime information" do
71
- should be_true
72
- end
73
-
74
- context 'with runtime information' do
75
- include_context 'dynamic analysis objects'
76
-
77
- it 'returns false properly' do
78
- should be_false
79
- end
80
- end
81
- end
82
- end
83
-
84
- describe '#convert!' do
85
- before do
86
- current_example_object.convert! unless example.metadata[:no_auto_convert]
87
- end
88
-
89
- (RSpecDSL::EXAMPLE_METHODS + RSpecDSL::HOOK_METHODS).each do |method|
90
- context "with expression `#{method} do example end`" do
91
- let(:source) do
92
- <<-END
93
- describe 'example' do
94
- #{method} do
95
- do_something if example.metadata[:foo]
96
- end
97
- end
98
- END
99
- end
100
-
101
- let(:expected_source) do
102
- <<-END
103
- describe 'example' do
104
- #{method} do |example|
105
- do_something if example.metadata[:foo]
106
- end
107
- end
108
- END
109
- end
110
-
111
- it "converts to `#{method} do |example| example end` form" do
112
- rewritten_source.should == expected_source
113
- end
114
-
115
- it "adds record `#{method} { example }` -> `#{method} { |example| example }`" do
116
- record.old_syntax.should == "#{method} { example }"
117
- record.new_syntax.should == "#{method} { |example| example }"
118
- end
119
- end
120
- end
121
-
122
- RSpecDSL::HELPER_METHODS.each do |method|
123
- context "with expression `#{method}(:name) do example end`" do
124
- let(:source) do
125
- <<-END
126
- describe 'example' do
127
- #{method}(:name) do
128
- do_something if example.metadata[:foo]
129
- end
130
- end
131
- END
132
- end
133
-
134
- let(:expected_source) do
135
- <<-END
136
- describe 'example' do
137
- #{method}(:name) do |example|
138
- do_something if example.metadata[:foo]
139
- end
140
- end
141
- END
142
- end
143
-
144
- it "converts to `#{method}(:name) do |example| example end` form" do
145
- rewritten_source.should == expected_source
146
- end
147
-
148
- it "adds record `#{method}(:name) { example }` -> `#{method}(:name) { |example| example }`" do
149
- record.old_syntax.should == "#{method}(:name) { example }"
150
- record.new_syntax.should == "#{method}(:name) { |example| example }"
151
- end
152
- end
153
- end
154
-
155
- context 'with expression `after { example }`' do
156
- let(:source) do
157
- <<-END
158
- describe 'example' do
159
- after {
160
- do_something if example.metadata[:foo]
161
- }
162
- end
163
- END
164
- end
165
-
166
- let(:expected_source) do
167
- <<-END
168
- describe 'example' do
169
- after { |example|
170
- do_something if example.metadata[:foo]
171
- }
172
- end
173
- END
174
- end
175
-
176
- it 'converts to `after { |example| example }` form' do
177
- rewritten_source.should == expected_source
178
- end
179
- end
180
-
181
- context 'with expression `after do running_example end`' do
182
- let(:source) do
183
- <<-END
184
- describe 'example' do
185
- after do
186
- do_something if running_example.metadata[:foo]
187
- end
188
- end
189
- END
190
- end
191
-
192
- let(:expected_source) do
193
- <<-END
194
- describe 'example' do
195
- after do |example|
196
- do_something if example.metadata[:foo]
197
- end
198
- end
199
- END
200
- end
201
-
202
- it 'converts to `after do |example| example end` form' do
203
- rewritten_source.should == expected_source
204
- end
205
- end
206
-
207
- context 'when the wrapper block contains multiple invocation of `example`', :no_auto_convert do
208
- let(:source) do
209
- <<-END
210
- describe 'example' do
211
- after do
212
- do_something if example.metadata[:foo]
213
- puts example.description
214
- end
215
- end
216
- END
217
- end
218
-
219
- let(:expected_source) do
220
- <<-END
221
- describe 'example' do
222
- after do |example|
223
- do_something if example.metadata[:foo]
224
- puts example.description
225
- end
226
- end
227
- END
228
- end
229
-
230
- let(:current_example_objects) do
231
- ast.each_node.each_with_object([]) do |node, objects|
232
- current_example_object = CurrentExample.new(node, runtime_data, project, source_rewriter)
233
- objects << current_example_object if current_example_object.conversion_target?
234
- end
235
- end
236
-
237
- it 'adds only a block argument' do
238
- current_example_objects.size.should eq(2)
239
- current_example_objects.each(&:convert!)
240
- rewritten_source.should == expected_source
241
- end
242
- end
243
-
244
- context 'with expression `around do |ex| example end`' do
245
- let(:source) do
246
- <<-END
247
- describe 'example' do
248
- around do |ex|
249
- do_something if example.metadata[:foo]
250
- end
251
- end
252
- END
253
- end
254
-
255
- let(:expected_source) do
256
- <<-END
257
- describe 'example' do
258
- around do |ex|
259
- do_something if ex.metadata[:foo]
260
- end
261
- end
262
- END
263
- end
264
-
265
- it 'converts to `around do |ex| ex end` form' do
266
- rewritten_source.should == expected_source
267
- end
268
- end
269
-
270
- context 'with expression `def helper_method example; end`' do
271
- let(:source) do
272
- <<-END
273
- module Helper
274
- def display_description
275
- puts example.description
276
- end
277
- end
278
-
279
- describe 'example' do
280
- include Helper
281
-
282
- after do
283
- display_description
284
- end
285
- end
286
- END
287
- end
288
-
289
- let(:expected_source) do
290
- <<-END
291
- module Helper
292
- def display_description
293
- puts RSpec.current_example.description
294
- end
295
- end
296
-
297
- describe 'example' do
298
- include Helper
299
-
300
- after do
301
- display_description
302
- end
303
- end
304
- END
305
- end
306
-
307
- it 'converts to `def helper_method RSpec.current_example; end` form' do
308
- rewritten_source.should == expected_source
309
- end
310
-
311
- it 'adds record `def helper_method example; end` -> `def helper_method RSpec.current_example; end`' do
312
- record.old_syntax.should == 'def helper_method example; end'
313
- record.new_syntax.should == 'def helper_method RSpec.current_example; end'
314
- end
315
- end
316
- end
317
- end
318
- end
319
- end