transpec 1.9.3 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +1 -1
- data/CHANGELOG.md +5 -0
- data/CONTRIBUTING.md +19 -0
- data/README.md +78 -9
- data/README.md.erb +68 -10
- data/lib/transpec/annotatable.rb +16 -0
- data/lib/transpec/cli.rb +35 -27
- data/lib/transpec/configuration.rb +1 -0
- data/lib/transpec/conversion_error.rb +23 -0
- data/lib/transpec/converter.rb +59 -50
- data/lib/transpec/dynamic_analyzer.rb +13 -29
- data/lib/transpec/dynamic_analyzer/rewriter.rb +3 -10
- data/lib/transpec/dynamic_analyzer/runtime_data.rb +16 -8
- data/lib/transpec/file_finder.rb +1 -1
- data/lib/transpec/git.rb +1 -1
- data/lib/transpec/option_parser.rb +12 -10
- data/lib/transpec/project.rb +3 -3
- data/lib/transpec/record.rb +19 -2
- data/lib/transpec/report.rb +29 -13
- data/lib/transpec/rspec_version.rb +7 -7
- data/lib/transpec/static_context_inspector.rb +1 -5
- data/lib/transpec/syntax.rb +11 -16
- data/lib/transpec/syntax/be_boolean.rb +1 -1
- data/lib/transpec/syntax/be_close.rb +1 -1
- data/lib/transpec/syntax/current_example.rb +88 -0
- data/lib/transpec/syntax/double.rb +1 -1
- data/lib/transpec/syntax/example.rb +60 -54
- data/lib/transpec/syntax/have.rb +27 -15
- data/lib/transpec/syntax/have/have_record.rb +12 -0
- data/lib/transpec/syntax/have/source_builder.rb +18 -16
- data/lib/transpec/syntax/its.rb +12 -11
- data/lib/transpec/syntax/matcher_definition.rb +1 -1
- data/lib/transpec/syntax/method_stub.rb +3 -7
- data/lib/transpec/syntax/mixin/matcher_owner.rb +2 -2
- data/lib/transpec/syntax/mixin/monkey_patch.rb +3 -5
- data/lib/transpec/syntax/mixin/monkey_patch_any_instance.rb +2 -4
- data/lib/transpec/syntax/mixin/owned_matcher.rb +1 -4
- data/lib/transpec/syntax/mixin/send.rb +7 -9
- data/lib/transpec/syntax/oneliner_should.rb +4 -4
- data/lib/transpec/syntax/operator.rb +27 -11
- data/lib/transpec/syntax/pending.rb +110 -0
- data/lib/transpec/syntax/raise_error.rb +1 -1
- data/lib/transpec/syntax/receive.rb +4 -4
- data/lib/transpec/syntax/rspec_configure/framework.rb +3 -3
- data/lib/transpec/syntax/should.rb +2 -2
- data/lib/transpec/syntax/should_receive.rb +3 -3
- data/lib/transpec/util.rb +38 -6
- data/lib/transpec/version.rb +2 -2
- data/spec/support/file_helper.rb +1 -1
- data/spec/support/shared_context.rb +3 -8
- data/spec/transpec/cli_spec.rb +63 -1
- data/spec/transpec/configuration_spec.rb +1 -0
- data/spec/transpec/converter_spec.rb +106 -15
- data/spec/transpec/dynamic_analyzer/rewriter_spec.rb +12 -52
- data/spec/transpec/dynamic_analyzer_spec.rb +2 -2
- data/spec/transpec/option_parser_spec.rb +3 -2
- data/spec/transpec/report_spec.rb +33 -4
- data/spec/transpec/rspec_version_spec.rb +5 -2
- data/spec/transpec/syntax/current_example_spec.rb +267 -0
- data/spec/transpec/syntax/example_spec.rb +156 -122
- data/spec/transpec/syntax/have_spec.rb +43 -32
- data/spec/transpec/syntax/method_stub_spec.rb +8 -0
- data/spec/transpec/syntax/operator_spec.rb +67 -2
- data/spec/transpec/syntax/pending_spec.rb +375 -0
- metadata +12 -4
- data/lib/transpec/context_error.rb +0 -23
@@ -65,8 +65,9 @@ module Transpec
|
|
65
65
|
['oneliner', :convert_oneliner?],
|
66
66
|
['should_receive', :convert_should_receive?],
|
67
67
|
['stub', :convert_stub?],
|
68
|
-
['have_items', :convert_have_items],
|
69
|
-
['its', :convert_its],
|
68
|
+
['have_items', :convert_have_items?],
|
69
|
+
['its', :convert_its?],
|
70
|
+
['pending', :convert_pending?],
|
70
71
|
['deprecated', :convert_deprecated_method?]
|
71
72
|
].each do |cli_type, config_attr|
|
72
73
|
context "when #{cli_type.inspect} is specified" do
|
@@ -10,10 +10,10 @@ module Transpec
|
|
10
10
|
subject(:report) { Report.new }
|
11
11
|
|
12
12
|
before do
|
13
|
-
report.records << Record.new('obj.stub(:message)', 'allow(obj).to receive(:message)')
|
13
|
+
report.records << Record.new('obj.stub(:message)', 'allow(obj).to receive(:message)', double('annotation'))
|
14
14
|
report.records << Record.new('obj.should', 'expect(obj).to')
|
15
|
-
report.records << Record.new('obj.should', 'expect(obj).to')
|
16
|
-
report.
|
15
|
+
report.records << Record.new('obj.should', 'expect(obj).to', double('annotation'))
|
16
|
+
report.conversion_errors << ContextError.new('#should', '#expect', double('range'))
|
17
17
|
end
|
18
18
|
|
19
19
|
describe '#unique_record_counts' do
|
@@ -81,7 +81,36 @@ module Transpec
|
|
81
81
|
|
82
82
|
describe '#stats' do
|
83
83
|
it 'returns stats string' do
|
84
|
-
report.stats.should == '3 conversions, 1 incomplete, 0 errors'
|
84
|
+
report.stats.should == '3 conversions, 1 incomplete, 2 cautions, 0 errors'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe '#<<' do
|
89
|
+
subject(:concated_report) { report << another_report }
|
90
|
+
|
91
|
+
let(:another_report) do
|
92
|
+
report = Report.new
|
93
|
+
report.records << Record.new('obj.stub(:message)', 'allow(obj).to receive(:message)')
|
94
|
+
report.conversion_errors << ContextError.new('#should', '#expect', double('range'))
|
95
|
+
report.conversion_errors << ContextError.new('#stub', '#allow', double('range'))
|
96
|
+
report.syntax_errors << double('syntax error')
|
97
|
+
report
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'returns the receiver' do
|
101
|
+
concated_report.should equal(report)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'concats records' do
|
105
|
+
concated_report.should have(4).records
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'concats conversion errors' do
|
109
|
+
concated_report.should have(3).conversion_errors
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'concats syntax errors' do
|
113
|
+
concated_report.should have(1).syntax_errors
|
85
114
|
end
|
86
115
|
end
|
87
116
|
end
|
@@ -39,7 +39,10 @@ module Transpec
|
|
39
39
|
]
|
40
40
|
end
|
41
41
|
|
42
|
-
[
|
42
|
+
[
|
43
|
+
:oneliner_is_expected_available?,
|
44
|
+
:skip_available?
|
45
|
+
].each do |method|
|
43
46
|
include_examples 'version comparisons', method, [
|
44
47
|
['2.14.0', false],
|
45
48
|
['2.99.0.beta1', false],
|
@@ -75,7 +78,7 @@ module Transpec
|
|
75
78
|
]
|
76
79
|
end
|
77
80
|
|
78
|
-
include_examples 'version comparisons', :
|
81
|
+
include_examples 'version comparisons', :rspec_2_99?, [
|
79
82
|
['2.14.0', false],
|
80
83
|
['2.99.0.beta1', true],
|
81
84
|
['2.99.0.beta2', true],
|
@@ -0,0 +1,267 @@
|
|
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 '#convert!' do
|
15
|
+
before do
|
16
|
+
current_example_object.convert! unless example.metadata[:no_auto_convert]
|
17
|
+
end
|
18
|
+
|
19
|
+
(RSpecDSL::EXAMPLE_METHODS + RSpecDSL::HOOK_METHODS).each do |method|
|
20
|
+
context "when it is `#{method} do example end` form" do
|
21
|
+
let(:source) do
|
22
|
+
<<-END
|
23
|
+
describe 'example' do
|
24
|
+
#{method} do
|
25
|
+
do_something if example.metadata[:foo]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
END
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:expected_source) do
|
32
|
+
<<-END
|
33
|
+
describe 'example' do
|
34
|
+
#{method} do |example|
|
35
|
+
do_something if example.metadata[:foo]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
END
|
39
|
+
end
|
40
|
+
|
41
|
+
it "converts into `#{method} do |example| example end` form" do
|
42
|
+
rewritten_source.should == expected_source
|
43
|
+
end
|
44
|
+
|
45
|
+
it "adds record `#{method} { example }` -> `#{method} { |example| example }`" do
|
46
|
+
record.original_syntax.should == "#{method} { example }"
|
47
|
+
record.converted_syntax.should == "#{method} { |example| example }"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
RSpecDSL::HELPER_METHODS.each do |method|
|
53
|
+
context "when it is `#{method}(:name) do example end` form" do
|
54
|
+
let(:source) do
|
55
|
+
<<-END
|
56
|
+
describe 'example' do
|
57
|
+
#{method}(:name) do
|
58
|
+
do_something if example.metadata[:foo]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
END
|
62
|
+
end
|
63
|
+
|
64
|
+
let(:expected_source) do
|
65
|
+
<<-END
|
66
|
+
describe 'example' do
|
67
|
+
#{method}(:name) do |example|
|
68
|
+
do_something if example.metadata[:foo]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
END
|
72
|
+
end
|
73
|
+
|
74
|
+
it "converts into `#{method}(:name) do |example| example end` form" do
|
75
|
+
rewritten_source.should == expected_source
|
76
|
+
end
|
77
|
+
|
78
|
+
it "adds record `#{method}(:name) { example }` -> `#{method}(:name) { |example| example }`" do
|
79
|
+
record.original_syntax.should == "#{method}(:name) { example }"
|
80
|
+
record.converted_syntax.should == "#{method}(:name) { |example| example }"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'when it is `after { example }` form' do
|
86
|
+
let(:source) do
|
87
|
+
<<-END
|
88
|
+
describe 'example' do
|
89
|
+
after {
|
90
|
+
do_something if example.metadata[:foo]
|
91
|
+
}
|
92
|
+
end
|
93
|
+
END
|
94
|
+
end
|
95
|
+
|
96
|
+
let(:expected_source) do
|
97
|
+
<<-END
|
98
|
+
describe 'example' do
|
99
|
+
after { |example|
|
100
|
+
do_something if example.metadata[:foo]
|
101
|
+
}
|
102
|
+
end
|
103
|
+
END
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'converts into `after { |example| example }` form' do
|
107
|
+
rewritten_source.should == expected_source
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'when it is `after do running_example end` form' do
|
112
|
+
let(:source) do
|
113
|
+
<<-END
|
114
|
+
describe 'example' do
|
115
|
+
after do
|
116
|
+
do_something if running_example.metadata[:foo]
|
117
|
+
end
|
118
|
+
end
|
119
|
+
END
|
120
|
+
end
|
121
|
+
|
122
|
+
let(:expected_source) do
|
123
|
+
<<-END
|
124
|
+
describe 'example' do
|
125
|
+
after do |example|
|
126
|
+
do_something if example.metadata[:foo]
|
127
|
+
end
|
128
|
+
end
|
129
|
+
END
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'converts into `after do |example| example end` form' do
|
133
|
+
rewritten_source.should == expected_source
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context 'when the wrapper block contains multiple invocation of `example`', :no_auto_convert do
|
138
|
+
let(:source) do
|
139
|
+
<<-END
|
140
|
+
describe 'example' do
|
141
|
+
after do
|
142
|
+
do_something if example.metadata[:foo]
|
143
|
+
puts example.description
|
144
|
+
end
|
145
|
+
end
|
146
|
+
END
|
147
|
+
end
|
148
|
+
|
149
|
+
let(:expected_source) do
|
150
|
+
<<-END
|
151
|
+
describe 'example' do
|
152
|
+
after do |example|
|
153
|
+
do_something if example.metadata[:foo]
|
154
|
+
puts example.description
|
155
|
+
end
|
156
|
+
end
|
157
|
+
END
|
158
|
+
end
|
159
|
+
|
160
|
+
let(:current_example_objects) do
|
161
|
+
ast.each_node.reduce([]) do |objects, node|
|
162
|
+
if CurrentExample.conversion_target_node?(node)
|
163
|
+
objects << CurrentExample.new(node, source_rewriter, runtime_data)
|
164
|
+
end
|
165
|
+
objects
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'adds only a block argument' do
|
170
|
+
current_example_objects.size.should eq(2)
|
171
|
+
current_example_objects.each(&:convert!)
|
172
|
+
rewritten_source.should == expected_source
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context 'when it is `around do |ex| example end` form' do
|
177
|
+
let(:source) do
|
178
|
+
<<-END
|
179
|
+
describe 'example' do
|
180
|
+
around do |ex|
|
181
|
+
do_something if example.metadata[:foo]
|
182
|
+
end
|
183
|
+
end
|
184
|
+
END
|
185
|
+
end
|
186
|
+
|
187
|
+
let(:expected_source) do
|
188
|
+
<<-END
|
189
|
+
describe 'example' do
|
190
|
+
around do |ex|
|
191
|
+
do_something if ex.metadata[:foo]
|
192
|
+
end
|
193
|
+
end
|
194
|
+
END
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'converts into `around do |ex| ex end` form' do
|
198
|
+
rewritten_source.should == expected_source
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
context "when it is `example 'it does something' do do_something end` form", :no_auto_convert do
|
203
|
+
let(:source) do
|
204
|
+
<<-END
|
205
|
+
describe 'example' do
|
206
|
+
example 'it does something' do
|
207
|
+
do_something
|
208
|
+
end
|
209
|
+
end
|
210
|
+
END
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'does nothing' do
|
214
|
+
rewritten_source.should == source
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
context 'when it is `def helper_method example; end` form' do
|
219
|
+
let(:source) do
|
220
|
+
<<-END
|
221
|
+
module Helper
|
222
|
+
def display_description
|
223
|
+
puts example.description
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
describe 'example' do
|
228
|
+
include Helper
|
229
|
+
|
230
|
+
after do
|
231
|
+
display_description
|
232
|
+
end
|
233
|
+
end
|
234
|
+
END
|
235
|
+
end
|
236
|
+
|
237
|
+
let(:expected_source) do
|
238
|
+
<<-END
|
239
|
+
module Helper
|
240
|
+
def display_description
|
241
|
+
puts RSpec.current_example.description
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
describe 'example' do
|
246
|
+
include Helper
|
247
|
+
|
248
|
+
after do
|
249
|
+
display_description
|
250
|
+
end
|
251
|
+
end
|
252
|
+
END
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'converts into `def helper_method RSpec.current_example; end` form' do
|
256
|
+
rewritten_source.should == expected_source
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'adds record `def helper_method example; end` -> `def helper_method RSpec.current_example; end`' do
|
260
|
+
record.original_syntax.should == 'def helper_method example; end'
|
261
|
+
record.converted_syntax.should == 'def helper_method RSpec.current_example; end'
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
@@ -2,181 +2,164 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
require 'transpec/syntax/example'
|
5
|
+
require 'ast'
|
5
6
|
|
6
7
|
module Transpec
|
7
8
|
class Syntax
|
8
9
|
describe Example do
|
10
|
+
include ::AST::Sexp
|
9
11
|
include_context 'parsed objects'
|
10
12
|
include_context 'syntax object', Example, :example_object
|
11
13
|
|
12
14
|
let(:record) { example_object.report.records.last }
|
13
15
|
|
14
|
-
describe '
|
15
|
-
|
16
|
-
example_object.convert! unless example.metadata[:no_auto_convert]
|
17
|
-
end
|
18
|
-
|
19
|
-
(RSpecDSL::EXAMPLE_METHODS + RSpecDSL::HOOK_METHODS).each do |method|
|
20
|
-
context "when it is `#{method} do example end` form" do
|
21
|
-
let(:source) do
|
22
|
-
<<-END
|
23
|
-
describe 'example' do
|
24
|
-
#{method} do
|
25
|
-
do_something if example.metadata[:foo]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
END
|
29
|
-
end
|
30
|
-
|
31
|
-
let(:expected_source) do
|
32
|
-
<<-END
|
33
|
-
describe 'example' do
|
34
|
-
#{method} do |example|
|
35
|
-
do_something if example.metadata[:foo]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
END
|
39
|
-
end
|
40
|
-
|
41
|
-
it "converts into `#{method} do |example| example end` form" do
|
42
|
-
rewritten_source.should == expected_source
|
43
|
-
end
|
16
|
+
describe '.conversion_target_node?' do
|
17
|
+
subject { Example.conversion_target_node?(pending_node, runtime_data) }
|
44
18
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
19
|
+
let(:pending_node) do
|
20
|
+
ast.each_descendent_node do |node|
|
21
|
+
next unless node.send_type?
|
22
|
+
method_name = node.children[1]
|
23
|
+
return node if method_name == :pending
|
49
24
|
end
|
25
|
+
fail 'No #pending node is found!'
|
50
26
|
end
|
51
27
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
#{method}(:name) do
|
58
|
-
do_something if example.metadata[:foo]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
END
|
62
|
-
end
|
63
|
-
|
64
|
-
let(:expected_source) do
|
65
|
-
<<-END
|
66
|
-
describe 'example' do
|
67
|
-
#{method}(:name) do |example|
|
68
|
-
do_something if example.metadata[:foo]
|
69
|
-
end
|
28
|
+
context 'when #pending example node is passed' do
|
29
|
+
let(:source) do
|
30
|
+
<<-END
|
31
|
+
describe 'example' do
|
32
|
+
pending 'will be skipped' do
|
70
33
|
end
|
71
|
-
|
72
|
-
|
34
|
+
end
|
35
|
+
END
|
36
|
+
end
|
73
37
|
|
74
|
-
|
75
|
-
|
76
|
-
|
38
|
+
context 'without runtime information' do
|
39
|
+
it { should be_true }
|
40
|
+
end
|
77
41
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
42
|
+
context 'with runtime information' do
|
43
|
+
include_context 'dynamic analysis objects'
|
44
|
+
it { should be_true }
|
82
45
|
end
|
83
46
|
end
|
84
47
|
|
85
|
-
context 'when
|
48
|
+
context 'when #pending specification node inside of an example is passed' do
|
86
49
|
let(:source) do
|
87
50
|
<<-END
|
88
51
|
describe 'example' do
|
89
|
-
|
90
|
-
|
91
|
-
|
52
|
+
it 'will be skipped' do
|
53
|
+
pending
|
54
|
+
end
|
92
55
|
end
|
93
56
|
END
|
94
57
|
end
|
95
58
|
|
96
|
-
|
59
|
+
context 'without runtime information' do
|
60
|
+
it { should be_false }
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'with runtime information' do
|
64
|
+
include_context 'dynamic analysis objects'
|
65
|
+
it { should be_false }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#metadata_key_nodes' do
|
71
|
+
subject { example_object.metadata_key_nodes }
|
72
|
+
|
73
|
+
context 'when it is `it { }` form' do
|
74
|
+
let(:source) do
|
97
75
|
<<-END
|
98
76
|
describe 'example' do
|
99
|
-
|
100
|
-
do_something if example.metadata[:foo]
|
101
|
-
}
|
77
|
+
it { do_something }
|
102
78
|
end
|
103
79
|
END
|
104
80
|
end
|
105
81
|
|
106
|
-
it '
|
107
|
-
|
82
|
+
it 'returns empty array' do
|
83
|
+
should be_empty
|
108
84
|
end
|
109
85
|
end
|
110
86
|
|
111
|
-
context
|
87
|
+
context "when it is `it 'description' { }` form" do
|
112
88
|
let(:source) do
|
113
89
|
<<-END
|
114
90
|
describe 'example' do
|
115
|
-
|
116
|
-
do_something
|
91
|
+
it 'is an example' do
|
92
|
+
do_something
|
117
93
|
end
|
118
94
|
end
|
119
95
|
END
|
120
96
|
end
|
121
97
|
|
122
|
-
|
98
|
+
it 'returns empty array' do
|
99
|
+
should be_empty
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context "when it is `it 'description', :foo { }` form" do
|
104
|
+
let(:source) do
|
123
105
|
<<-END
|
124
106
|
describe 'example' do
|
125
|
-
|
126
|
-
do_something
|
107
|
+
it 'is an example', :foo do
|
108
|
+
do_something
|
127
109
|
end
|
128
110
|
end
|
129
111
|
END
|
130
112
|
end
|
131
113
|
|
132
|
-
it '
|
133
|
-
|
114
|
+
it 'returns [(sym :foo)]' do
|
115
|
+
should == [s(:sym, :foo)]
|
134
116
|
end
|
135
117
|
end
|
136
118
|
|
137
|
-
context
|
119
|
+
context "when it is `it 'description', foo: true { }` form" do
|
138
120
|
let(:source) do
|
139
121
|
<<-END
|
140
122
|
describe 'example' do
|
141
|
-
|
142
|
-
do_something
|
143
|
-
puts example.description
|
123
|
+
it 'is an example', foo: true do
|
124
|
+
do_something
|
144
125
|
end
|
145
126
|
end
|
146
127
|
END
|
147
128
|
end
|
148
129
|
|
149
|
-
|
130
|
+
it 'returns [(sym :foo)]' do
|
131
|
+
should == [s(:sym, :foo)]
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context "when it is `it 'description', :foo, :bar, baz: true { }` form" do
|
136
|
+
let(:source) do
|
150
137
|
<<-END
|
151
138
|
describe 'example' do
|
152
|
-
|
153
|
-
do_something
|
154
|
-
puts example.description
|
139
|
+
it 'is an example', :foo, :bar, baz: true do
|
140
|
+
do_something
|
155
141
|
end
|
156
142
|
end
|
157
143
|
END
|
158
144
|
end
|
159
145
|
|
160
|
-
|
161
|
-
|
162
|
-
objects << Example.new(node, source_rewriter, runtime_data) if Example.conversion_target_node?(node)
|
163
|
-
objects
|
164
|
-
end
|
146
|
+
it 'returns [s(:sym, :foo), s(:sym, :bar), s(:sym, :baz)]' do
|
147
|
+
should == [s(:sym, :foo), s(:sym, :bar), s(:sym, :baz)]
|
165
148
|
end
|
149
|
+
end
|
150
|
+
end
|
166
151
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
rewritten_source.should == expected_source
|
171
|
-
end
|
152
|
+
describe '#convert_pending_to_skip!' do
|
153
|
+
before do
|
154
|
+
example_object.convert_pending_to_skip!
|
172
155
|
end
|
173
156
|
|
174
|
-
context
|
157
|
+
context "when it is `pending 'is an example' { }` form" do
|
175
158
|
let(:source) do
|
176
159
|
<<-END
|
177
160
|
describe 'example' do
|
178
|
-
|
179
|
-
do_something
|
161
|
+
pending 'will be skipped' do
|
162
|
+
do_something
|
180
163
|
end
|
181
164
|
end
|
182
165
|
END
|
@@ -185,23 +168,28 @@ module Transpec
|
|
185
168
|
let(:expected_source) do
|
186
169
|
<<-END
|
187
170
|
describe 'example' do
|
188
|
-
|
189
|
-
do_something
|
171
|
+
skip 'will be skipped' do
|
172
|
+
do_something
|
190
173
|
end
|
191
174
|
end
|
192
175
|
END
|
193
176
|
end
|
194
177
|
|
195
|
-
it
|
178
|
+
it "converts into `skip 'is an example' { }` form" do
|
196
179
|
rewritten_source.should == expected_source
|
197
180
|
end
|
181
|
+
|
182
|
+
it "adds record `pending 'is an example' { }` -> `skip 'is an example' { }`" do
|
183
|
+
record.original_syntax.should == "pending 'is an example' { }"
|
184
|
+
record.converted_syntax.should == "skip 'is an example' { }"
|
185
|
+
end
|
198
186
|
end
|
199
187
|
|
200
|
-
context "when it is `
|
188
|
+
context "when it is `it 'is an example' { }` form" do
|
201
189
|
let(:source) do
|
202
190
|
<<-END
|
203
191
|
describe 'example' do
|
204
|
-
|
192
|
+
it 'is normal example' do
|
205
193
|
do_something
|
206
194
|
end
|
207
195
|
end
|
@@ -213,20 +201,43 @@ module Transpec
|
|
213
201
|
end
|
214
202
|
end
|
215
203
|
|
216
|
-
context
|
204
|
+
context "when it is `it 'is an example', :pending { }` form" do
|
217
205
|
let(:source) do
|
218
206
|
<<-END
|
219
|
-
|
220
|
-
|
221
|
-
|
207
|
+
describe 'example' do
|
208
|
+
it 'will be skipped', :pending do
|
209
|
+
do_something
|
222
210
|
end
|
223
211
|
end
|
212
|
+
END
|
213
|
+
end
|
224
214
|
|
215
|
+
let(:expected_source) do
|
216
|
+
<<-END
|
225
217
|
describe 'example' do
|
226
|
-
|
218
|
+
it 'will be skipped', :skip do
|
219
|
+
do_something
|
220
|
+
end
|
221
|
+
end
|
222
|
+
END
|
223
|
+
end
|
224
|
+
|
225
|
+
it "converts into `it 'is an example', :skip { }` form" do
|
226
|
+
rewritten_source.should == expected_source
|
227
|
+
end
|
227
228
|
|
228
|
-
|
229
|
-
|
229
|
+
it "adds record `it 'is an example', :pending { }` -> `it 'is an example', :skip { }`" do
|
230
|
+
record.original_syntax.should == "it 'is an example', :pending { }"
|
231
|
+
record.converted_syntax.should == "it 'is an example', :skip { }"
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
context "when it is `it 'description', :pending => true { }` form" do
|
236
|
+
let(:source) do
|
237
|
+
<<-END
|
238
|
+
describe 'example' do
|
239
|
+
it 'will be skipped', :pending => true do
|
240
|
+
do_something
|
230
241
|
end
|
231
242
|
end
|
232
243
|
END
|
@@ -234,29 +245,52 @@ module Transpec
|
|
234
245
|
|
235
246
|
let(:expected_source) do
|
236
247
|
<<-END
|
237
|
-
|
238
|
-
|
239
|
-
|
248
|
+
describe 'example' do
|
249
|
+
it 'will be skipped', :skip => true do
|
250
|
+
do_something
|
240
251
|
end
|
241
252
|
end
|
253
|
+
END
|
254
|
+
end
|
255
|
+
|
256
|
+
it "converts into `it 'description', :skip => true { }` form" do
|
257
|
+
rewritten_source.should == expected_source
|
258
|
+
end
|
259
|
+
|
260
|
+
it "adds record `it 'is an example', :pending => value { }` -> `it 'is an example', :skip => value { }`" do
|
261
|
+
record.original_syntax.should == "it 'is an example', :pending => value { }"
|
262
|
+
record.converted_syntax.should == "it 'is an example', :skip => value { }"
|
263
|
+
end
|
264
|
+
end
|
242
265
|
|
266
|
+
context "when it is `it 'description', pending: true { }` form" do
|
267
|
+
let(:source) do
|
268
|
+
<<-END
|
243
269
|
describe 'example' do
|
244
|
-
|
270
|
+
it 'will be skipped', pending: true do
|
271
|
+
do_something
|
272
|
+
end
|
273
|
+
end
|
274
|
+
END
|
275
|
+
end
|
245
276
|
|
246
|
-
|
247
|
-
|
277
|
+
let(:expected_source) do
|
278
|
+
<<-END
|
279
|
+
describe 'example' do
|
280
|
+
it 'will be skipped', skip: true do
|
281
|
+
do_something
|
248
282
|
end
|
249
283
|
end
|
250
284
|
END
|
251
285
|
end
|
252
286
|
|
253
|
-
it
|
287
|
+
it "converts into `it 'description', skip: true { }` form" do
|
254
288
|
rewritten_source.should == expected_source
|
255
289
|
end
|
256
290
|
|
257
|
-
it
|
258
|
-
record.original_syntax.should == '
|
259
|
-
record.converted_syntax.should == '
|
291
|
+
it "adds record `it 'is an example', :pending => value { }` -> `it 'is an example', :skip => value { }`" do
|
292
|
+
record.original_syntax.should == "it 'is an example', :pending => value { }"
|
293
|
+
record.converted_syntax.should == "it 'is an example', :skip => value { }"
|
260
294
|
end
|
261
295
|
end
|
262
296
|
end
|