transpec 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +4 -0
- data/lib/transpec/version.rb +1 -1
- data/transpec.gemspec +4 -3
- metadata +3 -97
- data/spec/.rubocop.yml +0 -23
- data/spec/integration/configuration_modification_spec.rb +0 -186
- data/spec/integration/conversion_spec.rb +0 -145
- data/spec/spec_helper.rb +0 -52
- data/spec/support/cache_helper.rb +0 -62
- data/spec/support/file_helper.rb +0 -25
- data/spec/support/shared_context.rb +0 -84
- data/spec/transpec/cli_spec.rb +0 -341
- data/spec/transpec/commit_message_spec.rb +0 -81
- data/spec/transpec/config_spec.rb +0 -99
- data/spec/transpec/converter_spec.rb +0 -1374
- data/spec/transpec/directory_cloner_spec.rb +0 -74
- data/spec/transpec/dynamic_analyzer/rewriter_spec.rb +0 -143
- data/spec/transpec/dynamic_analyzer_spec.rb +0 -329
- data/spec/transpec/git_spec.rb +0 -151
- data/spec/transpec/option_parser_spec.rb +0 -275
- data/spec/transpec/processed_source_spec.rb +0 -93
- data/spec/transpec/project_spec.rb +0 -194
- data/spec/transpec/record_spec.rb +0 -128
- data/spec/transpec/report_spec.rb +0 -126
- data/spec/transpec/rspec_version_spec.rb +0 -129
- data/spec/transpec/spec_file_finder_spec.rb +0 -118
- data/spec/transpec/spec_suite_spec.rb +0 -108
- data/spec/transpec/static_context_inspector_spec.rb +0 -713
- data/spec/transpec/syntax/allow_spec.rb +0 -122
- data/spec/transpec/syntax/be_boolean_spec.rb +0 -176
- data/spec/transpec/syntax/be_close_spec.rb +0 -51
- data/spec/transpec/syntax/current_example_spec.rb +0 -319
- data/spec/transpec/syntax/double_spec.rb +0 -175
- data/spec/transpec/syntax/example_group_spec.rb +0 -716
- data/spec/transpec/syntax/example_spec.rb +0 -301
- data/spec/transpec/syntax/expect_spec.rb +0 -313
- data/spec/transpec/syntax/have_spec.rb +0 -1276
- data/spec/transpec/syntax/hook_spec.rb +0 -215
- data/spec/transpec/syntax/its_spec.rb +0 -448
- data/spec/transpec/syntax/matcher_definition_spec.rb +0 -59
- data/spec/transpec/syntax/method_stub_spec.rb +0 -1301
- data/spec/transpec/syntax/oneliner_should_spec.rb +0 -628
- data/spec/transpec/syntax/operator_spec.rb +0 -871
- data/spec/transpec/syntax/pending_spec.rb +0 -415
- data/spec/transpec/syntax/raise_error_spec.rb +0 -354
- data/spec/transpec/syntax/receive_spec.rb +0 -499
- data/spec/transpec/syntax/rspec_configure_spec.rb +0 -870
- data/spec/transpec/syntax/should_receive_spec.rb +0 -1108
- data/spec/transpec/syntax/should_spec.rb +0 -497
- data/spec/transpec/util_spec.rb +0 -115
- data/spec/transpec_spec.rb +0 -22
@@ -1,175 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'transpec/syntax/double'
|
5
|
-
|
6
|
-
module Transpec
|
7
|
-
class Syntax
|
8
|
-
describe Double do
|
9
|
-
include_context 'parsed objects'
|
10
|
-
include_context 'syntax object', Double, :double_object
|
11
|
-
|
12
|
-
describe '#conversion_target?' do
|
13
|
-
let(:target_node) do
|
14
|
-
ast.each_node(:send).find do |send_node|
|
15
|
-
method_name = send_node.children[1]
|
16
|
-
method_name == :double
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
let(:double_object) do
|
21
|
-
Double.new(target_node, runtime_data)
|
22
|
-
end
|
23
|
-
|
24
|
-
subject { double_object.conversion_target? }
|
25
|
-
|
26
|
-
context 'when #double node is passed' do
|
27
|
-
let(:source) do
|
28
|
-
<<-END
|
29
|
-
describe 'example' do
|
30
|
-
it 'includes something' do
|
31
|
-
something = double('something')
|
32
|
-
[1, something].should include(something)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
END
|
36
|
-
end
|
37
|
-
|
38
|
-
it { should be_true }
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'with runtime information' do
|
42
|
-
include_context 'dynamic analysis objects'
|
43
|
-
|
44
|
-
context "when RSpec's #double node is passed" do
|
45
|
-
let(:source) do
|
46
|
-
<<-END
|
47
|
-
describe 'example' do
|
48
|
-
it 'includes something' do
|
49
|
-
something = double('something')
|
50
|
-
[1, something].should include(something)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
END
|
54
|
-
end
|
55
|
-
|
56
|
-
it { should be_true }
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'when another #double node is passed' do
|
60
|
-
let(:source) do
|
61
|
-
<<-END
|
62
|
-
module AnotherMockFramework
|
63
|
-
def setup_mocks_for_rspec
|
64
|
-
def double(arg)
|
65
|
-
arg.upcase
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def verify_mocks_for_rspec
|
70
|
-
end
|
71
|
-
|
72
|
-
def teardown_mocks_for_rspec
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
RSpec.configure do |config|
|
77
|
-
config.mock_framework = AnotherMockFramework
|
78
|
-
end
|
79
|
-
|
80
|
-
describe 'example' do
|
81
|
-
it "is not RSpec's #double" do
|
82
|
-
something = double('something')
|
83
|
-
[1, something].should include('SOMETHING')
|
84
|
-
end
|
85
|
-
end
|
86
|
-
END
|
87
|
-
end
|
88
|
-
|
89
|
-
it { should be_false }
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe '#method_name' do
|
95
|
-
let(:source) do
|
96
|
-
<<-END
|
97
|
-
describe 'example' do
|
98
|
-
it 'includes something' do
|
99
|
-
something = double('something')
|
100
|
-
[1, something].should include(something)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
END
|
104
|
-
end
|
105
|
-
|
106
|
-
it 'returns the method name' do
|
107
|
-
double_object.method_name.should == :double
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe '#convert_to_double!' do
|
112
|
-
before do
|
113
|
-
double_object.convert_to_double!
|
114
|
-
end
|
115
|
-
|
116
|
-
[:mock, :stub].each do |method|
|
117
|
-
context "with expression `#{method}('something')`" do
|
118
|
-
let(:source) do
|
119
|
-
<<-END
|
120
|
-
describe 'example' do
|
121
|
-
it 'includes something' do
|
122
|
-
something = #{method}('something')
|
123
|
-
[1, something].should include(something)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
END
|
127
|
-
end
|
128
|
-
|
129
|
-
let(:expected_source) do
|
130
|
-
<<-END
|
131
|
-
describe 'example' do
|
132
|
-
it 'includes something' do
|
133
|
-
something = double('something')
|
134
|
-
[1, something].should include(something)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
END
|
138
|
-
end
|
139
|
-
|
140
|
-
it "converts to `#{method}('something')`" do
|
141
|
-
rewritten_source.should == expected_source
|
142
|
-
end
|
143
|
-
|
144
|
-
it "adds record `#{method}('something')` -> `double('something')`" do
|
145
|
-
record = double_object.report.records.first
|
146
|
-
record.old_syntax.should == "#{method}('something')"
|
147
|
-
record.new_syntax.should == "double('something')"
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
context "with expression `double('something')`" do
|
153
|
-
let(:source) do
|
154
|
-
<<-END
|
155
|
-
describe 'example' do
|
156
|
-
it 'includes something' do
|
157
|
-
something = double('something')
|
158
|
-
[1, something].should include(something)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
END
|
162
|
-
end
|
163
|
-
|
164
|
-
it 'does nothing' do
|
165
|
-
rewritten_source.should == source
|
166
|
-
end
|
167
|
-
|
168
|
-
it 'reports nothing' do
|
169
|
-
double_object.report.records.should be_empty
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
@@ -1,716 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'transpec/syntax/example_group'
|
5
|
-
require 'ast'
|
6
|
-
require 'active_support/core_ext/string/strip.rb'
|
7
|
-
|
8
|
-
module Transpec
|
9
|
-
class Syntax
|
10
|
-
describe ExampleGroup do
|
11
|
-
include ::AST::Sexp, FileHelper
|
12
|
-
include_context 'parsed objects'
|
13
|
-
include_context 'syntax object', ExampleGroup, :example_group
|
14
|
-
|
15
|
-
let(:record) { example_group.report.records.first }
|
16
|
-
|
17
|
-
describe '#convert_to_non_monkey_patch!' do
|
18
|
-
context 'when it is in top level scope' do
|
19
|
-
[
|
20
|
-
:describe,
|
21
|
-
:shared_examples,
|
22
|
-
:shared_context,
|
23
|
-
:share_examples_for,
|
24
|
-
:shared_examples_for
|
25
|
-
].each do |method|
|
26
|
-
context "with expression `#{method} 'something' do ... end`" do
|
27
|
-
let(:source) do
|
28
|
-
<<-END
|
29
|
-
#{method} 'something' do
|
30
|
-
end
|
31
|
-
END
|
32
|
-
end
|
33
|
-
|
34
|
-
let(:expected_source) do
|
35
|
-
<<-END
|
36
|
-
RSpec.#{method} 'something' do
|
37
|
-
end
|
38
|
-
END
|
39
|
-
end
|
40
|
-
|
41
|
-
it "converts to `RSpec.#{method} 'something' do ... end`" do
|
42
|
-
example_group.convert_to_non_monkey_patch!
|
43
|
-
rewritten_source.should == expected_source
|
44
|
-
end
|
45
|
-
|
46
|
-
it "adds record `#{method} 'something' { }` -> `RSpec.#{method} 'something' { }`" do
|
47
|
-
example_group.convert_to_non_monkey_patch!
|
48
|
-
record.old_syntax.should == "#{method} 'something' { }"
|
49
|
-
record.new_syntax.should == "RSpec.#{method} 'something' { }"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context "with expression `RSpec.describe 'something' do ... end`" do
|
56
|
-
let(:source) do
|
57
|
-
<<-END
|
58
|
-
RSpec.describe 'something' do
|
59
|
-
end
|
60
|
-
END
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'does nothing' do
|
64
|
-
example_group.convert_to_non_monkey_patch!
|
65
|
-
rewritten_source.should == source
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context 'when the #describe is in a module' do
|
70
|
-
let(:source) do
|
71
|
-
<<-END
|
72
|
-
module SomeModule
|
73
|
-
describe 'something' do
|
74
|
-
end
|
75
|
-
end
|
76
|
-
END
|
77
|
-
end
|
78
|
-
|
79
|
-
let(:expected_source) do
|
80
|
-
<<-END
|
81
|
-
module SomeModule
|
82
|
-
RSpec.describe 'something' do
|
83
|
-
end
|
84
|
-
end
|
85
|
-
END
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'converts' do
|
89
|
-
example_group.convert_to_non_monkey_patch!
|
90
|
-
rewritten_source.should == expected_source
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
shared_context 'multiple #describes' do
|
95
|
-
before do
|
96
|
-
ast.each_node do |node|
|
97
|
-
example_group = described_class.new(node, runtime_data, project, source_rewriter)
|
98
|
-
next unless example_group.conversion_target?
|
99
|
-
example_group.convert_to_non_monkey_patch!
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context 'when #describes are nested' do
|
105
|
-
include_context 'multiple #describes'
|
106
|
-
|
107
|
-
let(:source) do
|
108
|
-
<<-END
|
109
|
-
describe 'something' do
|
110
|
-
describe '#some_method' do
|
111
|
-
end
|
112
|
-
end
|
113
|
-
END
|
114
|
-
end
|
115
|
-
|
116
|
-
let(:expected_source) do
|
117
|
-
<<-END
|
118
|
-
RSpec.describe 'something' do
|
119
|
-
describe '#some_method' do
|
120
|
-
end
|
121
|
-
end
|
122
|
-
END
|
123
|
-
end
|
124
|
-
|
125
|
-
it 'converts only the outermost #describe' do
|
126
|
-
rewritten_source.should == expected_source
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
context 'when the #describe is in another RSpec.describe' do
|
131
|
-
include_context 'multiple #describes'
|
132
|
-
|
133
|
-
let(:source) do
|
134
|
-
<<-END
|
135
|
-
RSpec.describe 'something' do
|
136
|
-
describe '#some_method' do
|
137
|
-
end
|
138
|
-
end
|
139
|
-
END
|
140
|
-
end
|
141
|
-
|
142
|
-
context 'without runtime information' do
|
143
|
-
it 'does nothing' do
|
144
|
-
rewritten_source.should == source
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
context 'with runtime information' do
|
149
|
-
include_context 'dynamic analysis objects'
|
150
|
-
|
151
|
-
it 'does nothing' do
|
152
|
-
rewritten_source.should == source
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
context 'when logical-inner #describe is placed outside of the outer #describe in source' do
|
158
|
-
include_context 'multiple #describes'
|
159
|
-
|
160
|
-
let(:source) do
|
161
|
-
<<-END
|
162
|
-
inner_proc = proc do
|
163
|
-
describe 'inner' do
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
describe 'outer' do
|
168
|
-
instance_eval(&inner_proc)
|
169
|
-
end
|
170
|
-
END
|
171
|
-
end
|
172
|
-
|
173
|
-
context 'without runtime information' do
|
174
|
-
let(:expected_source) do
|
175
|
-
<<-END
|
176
|
-
inner_proc = proc do
|
177
|
-
RSpec.describe 'inner' do
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
RSpec.describe 'outer' do
|
182
|
-
instance_eval(&inner_proc)
|
183
|
-
end
|
184
|
-
END
|
185
|
-
end
|
186
|
-
|
187
|
-
it 'unfortunately converts both #describe' do
|
188
|
-
rewritten_source.should == expected_source
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
context 'with runtime information' do
|
193
|
-
include_context 'dynamic analysis objects'
|
194
|
-
|
195
|
-
let(:expected_source) do
|
196
|
-
<<-END
|
197
|
-
inner_proc = proc do
|
198
|
-
describe 'inner' do
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
RSpec.describe 'outer' do
|
203
|
-
instance_eval(&inner_proc)
|
204
|
-
end
|
205
|
-
END
|
206
|
-
end
|
207
|
-
|
208
|
-
it 'properly converts only the outermost #describe' do
|
209
|
-
rewritten_source.should == expected_source
|
210
|
-
end
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
describe '#metadata_key_nodes' do
|
216
|
-
subject { example_group.metadata_key_nodes }
|
217
|
-
|
218
|
-
context "with expression `describe 'something' { }`" do
|
219
|
-
let(:source) do
|
220
|
-
<<-END
|
221
|
-
describe 'example' do
|
222
|
-
end
|
223
|
-
END
|
224
|
-
end
|
225
|
-
|
226
|
-
it 'returns empty array' do
|
227
|
-
should be_empty
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
context "with expression `describe 'something', '#some_method' { }`" do
|
232
|
-
let(:source) do
|
233
|
-
<<-END
|
234
|
-
describe 'something', '#some_method' do
|
235
|
-
end
|
236
|
-
END
|
237
|
-
end
|
238
|
-
|
239
|
-
it 'returns empty array' do
|
240
|
-
should be_empty
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
context "with expression `describe 'something', :foo { }`" do
|
245
|
-
let(:source) do
|
246
|
-
<<-END
|
247
|
-
describe 'something', :foo do
|
248
|
-
end
|
249
|
-
END
|
250
|
-
end
|
251
|
-
|
252
|
-
it 'returns [(sym :foo)]' do
|
253
|
-
should == [s(:sym, :foo)]
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
context "with expression `describe 'something', foo: true { }`" do
|
258
|
-
let(:source) do
|
259
|
-
<<-END
|
260
|
-
describe 'something', foo: true do
|
261
|
-
end
|
262
|
-
END
|
263
|
-
end
|
264
|
-
|
265
|
-
it 'returns [(sym :foo)]' do
|
266
|
-
should == [s(:sym, :foo)]
|
267
|
-
end
|
268
|
-
end
|
269
|
-
|
270
|
-
context "with expression `describe 'something', :foo, :bar, baz: true { }`" do
|
271
|
-
let(:source) do
|
272
|
-
<<-END
|
273
|
-
describe 'something', :foo, :bar, baz: true do
|
274
|
-
end
|
275
|
-
END
|
276
|
-
end
|
277
|
-
|
278
|
-
it 'returns [s(:sym, :foo), s(:sym, :bar), s(:sym, :baz)]' do
|
279
|
-
should == [s(:sym, :foo), s(:sym, :bar), s(:sym, :baz)]
|
280
|
-
end
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
describe '#add_explicit_type_metadata!' do
|
285
|
-
context 'in rspec-rails project' do
|
286
|
-
before do
|
287
|
-
example_group.stub(:rspec_rails?).and_return(true)
|
288
|
-
example_group.add_explicit_type_metadata!
|
289
|
-
end
|
290
|
-
|
291
|
-
context 'when it is in top level scope' do
|
292
|
-
context "and expression `describe 'something' do ... end`" do
|
293
|
-
let(:source) do
|
294
|
-
<<-END
|
295
|
-
describe 'something' do
|
296
|
-
end
|
297
|
-
END
|
298
|
-
end
|
299
|
-
|
300
|
-
{
|
301
|
-
'controllers' => :controller,
|
302
|
-
'helpers' => :helper,
|
303
|
-
'mailers' => :mailer,
|
304
|
-
'models' => :model,
|
305
|
-
'requests' => :request,
|
306
|
-
'integration' => :request,
|
307
|
-
'api' => :request,
|
308
|
-
'routing' => :routing,
|
309
|
-
'views' => :view,
|
310
|
-
'features' => :feature
|
311
|
-
}.each do |directory, type|
|
312
|
-
context "and the file path is \"spec/#{directory}/some_spec.rb\"" do
|
313
|
-
let(:source_path) { "spec/#{directory}/some_spec.rb" }
|
314
|
-
|
315
|
-
let(:expected_source) do
|
316
|
-
<<-END
|
317
|
-
describe 'something', :type => #{type.inspect} do
|
318
|
-
end
|
319
|
-
END
|
320
|
-
end
|
321
|
-
|
322
|
-
it "adds metadata \":type => #{type.inspect}\"" do
|
323
|
-
rewritten_source.should == expected_source
|
324
|
-
end
|
325
|
-
|
326
|
-
it "adds record `describe 'some #{type}' { }` " \
|
327
|
-
"-> `describe 'some #{type}', :type => #{type.inspect} { }`" do
|
328
|
-
record.old_syntax.should == "describe 'some #{type}' { }"
|
329
|
-
record.new_syntax.should == "describe 'some #{type}', :type => #{type.inspect} { }"
|
330
|
-
end
|
331
|
-
end
|
332
|
-
end
|
333
|
-
|
334
|
-
context 'and the file path is "spec/contollers/some_namespace/some_spec.rb"' do
|
335
|
-
let(:source_path) { 'spec/controllers/some_namespace/some_spec.rb' }
|
336
|
-
|
337
|
-
let(:expected_source) do
|
338
|
-
<<-END
|
339
|
-
describe 'something', :type => :controller do
|
340
|
-
end
|
341
|
-
END
|
342
|
-
end
|
343
|
-
|
344
|
-
it 'adds metadata ":type => :controller' do
|
345
|
-
rewritten_source.should == expected_source
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
context 'and the file path is "spec/unit/some_spec.rb"' do
|
350
|
-
let(:source_path) { 'spec/unit/some_spec.rb' }
|
351
|
-
|
352
|
-
it 'does nothing' do
|
353
|
-
rewritten_source.should == source
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
|
-
context 'and the file path is "features/controllers/some_spec.rb"' do
|
358
|
-
let(:source_path) { 'features/controllers/some_spec.rb' }
|
359
|
-
|
360
|
-
it 'does nothing' do
|
361
|
-
rewritten_source.should == source
|
362
|
-
end
|
363
|
-
end
|
364
|
-
end
|
365
|
-
|
366
|
-
context "and expression `describe 'something', :foo => :bar do ... end`" do
|
367
|
-
let(:source) do
|
368
|
-
<<-END
|
369
|
-
describe 'something', :foo => :bar do
|
370
|
-
end
|
371
|
-
END
|
372
|
-
end
|
373
|
-
|
374
|
-
context 'and the file path is "spec/controllers/some_spec.rb"' do
|
375
|
-
let(:source_path) { 'spec/controllers/some_spec.rb' }
|
376
|
-
|
377
|
-
let(:expected_source) do
|
378
|
-
<<-END
|
379
|
-
describe 'something', :type => :controller, :foo => :bar do
|
380
|
-
end
|
381
|
-
END
|
382
|
-
end
|
383
|
-
|
384
|
-
it 'adds metadata ":type => :controller" to the beginning of the hash metadata' do
|
385
|
-
rewritten_source.should == expected_source
|
386
|
-
end
|
387
|
-
end
|
388
|
-
end
|
389
|
-
|
390
|
-
context "and expression `describe 'something', '#some_method', :foo, :bar => true do ... end`" do
|
391
|
-
let(:source) do
|
392
|
-
<<-END
|
393
|
-
describe 'something', '#some_method', :foo, :bar => true do
|
394
|
-
end
|
395
|
-
END
|
396
|
-
end
|
397
|
-
|
398
|
-
context 'and the file path is "spec/controllers/some_spec.rb"' do
|
399
|
-
let(:source_path) { 'spec/controllers/some_spec.rb' }
|
400
|
-
|
401
|
-
let(:expected_source) do
|
402
|
-
<<-END
|
403
|
-
describe 'something', '#some_method', :foo, :type => :controller, :bar => true do
|
404
|
-
end
|
405
|
-
END
|
406
|
-
end
|
407
|
-
|
408
|
-
it 'adds metadata ":type => :controller" to the beginning of the hash metadata' do
|
409
|
-
rewritten_source.should == expected_source
|
410
|
-
end
|
411
|
-
end
|
412
|
-
end
|
413
|
-
|
414
|
-
context "and expression `describe 'something', foo: :bar do ... end`" do
|
415
|
-
let(:source) do
|
416
|
-
<<-END
|
417
|
-
describe 'something', foo: :bar do
|
418
|
-
end
|
419
|
-
END
|
420
|
-
end
|
421
|
-
|
422
|
-
context 'and the file path is "spec/controllers/some_spec.rb"' do
|
423
|
-
let(:source_path) { 'spec/controllers/some_spec.rb' }
|
424
|
-
|
425
|
-
let(:expected_source) do
|
426
|
-
<<-END
|
427
|
-
describe 'something', type: :controller, foo: :bar do
|
428
|
-
end
|
429
|
-
END
|
430
|
-
end
|
431
|
-
|
432
|
-
it 'adds metadata "type: :controller"' do
|
433
|
-
rewritten_source.should == expected_source
|
434
|
-
end
|
435
|
-
end
|
436
|
-
end
|
437
|
-
|
438
|
-
context "and expression `describe 'something', :type => :foo do ... end`" do
|
439
|
-
let(:source) do
|
440
|
-
<<-END
|
441
|
-
describe 'something', :type => :foo do
|
442
|
-
end
|
443
|
-
END
|
444
|
-
end
|
445
|
-
|
446
|
-
context 'and the file path is "spec/controllers/some_spec.rb"' do
|
447
|
-
let(:source_path) { 'spec/controllers/some_spec.rb' }
|
448
|
-
|
449
|
-
it 'does nothing' do
|
450
|
-
rewritten_source.should == source
|
451
|
-
end
|
452
|
-
end
|
453
|
-
end
|
454
|
-
|
455
|
-
context "and expression `RSpec.describe 'something' do ... end`" do
|
456
|
-
let(:source) do
|
457
|
-
<<-END
|
458
|
-
RSpec.describe 'something' do
|
459
|
-
end
|
460
|
-
END
|
461
|
-
end
|
462
|
-
|
463
|
-
context 'and the file path is "spec/controllers/some_spec.rb"' do
|
464
|
-
let(:source_path) { 'spec/controllers/some_spec.rb' }
|
465
|
-
|
466
|
-
let(:expected_source) do
|
467
|
-
<<-END
|
468
|
-
RSpec.describe 'something', :type => :controller do
|
469
|
-
end
|
470
|
-
END
|
471
|
-
end
|
472
|
-
|
473
|
-
it 'adds metadata ":type => :controller"' do
|
474
|
-
rewritten_source.should == expected_source
|
475
|
-
end
|
476
|
-
end
|
477
|
-
end
|
478
|
-
|
479
|
-
context "and expression `shared_examples 'something' do ... end`" do
|
480
|
-
let(:source) do
|
481
|
-
<<-END
|
482
|
-
shared_examples 'something' do
|
483
|
-
end
|
484
|
-
END
|
485
|
-
end
|
486
|
-
|
487
|
-
context 'and the file path is "spec/controllers/some_spec.rb"' do
|
488
|
-
let(:source_path) { 'spec/controllers/some_spec.rb' }
|
489
|
-
|
490
|
-
it 'does nothing' do
|
491
|
-
rewritten_source.should == source
|
492
|
-
end
|
493
|
-
end
|
494
|
-
end
|
495
|
-
end
|
496
|
-
|
497
|
-
context 'when #describes are nested' do
|
498
|
-
let(:source_path) { 'spec/controllers/some_spec.rb' }
|
499
|
-
|
500
|
-
let(:source) do
|
501
|
-
<<-END
|
502
|
-
describe 'something' do
|
503
|
-
describe '#some_method' do
|
504
|
-
end
|
505
|
-
end
|
506
|
-
END
|
507
|
-
end
|
508
|
-
|
509
|
-
let(:expected_source) do
|
510
|
-
<<-END
|
511
|
-
describe 'something', :type => :controller do
|
512
|
-
describe '#some_method' do
|
513
|
-
end
|
514
|
-
end
|
515
|
-
END
|
516
|
-
end
|
517
|
-
|
518
|
-
it 'adds the metadata only to the outmost #describe' do
|
519
|
-
rewritten_source.should == expected_source
|
520
|
-
end
|
521
|
-
end
|
522
|
-
end
|
523
|
-
|
524
|
-
context 'with runtime information' do
|
525
|
-
include_context 'dynamic analysis objects'
|
526
|
-
|
527
|
-
let(:source_path) { 'spec/controllers/some_spec.rb' }
|
528
|
-
|
529
|
-
before do
|
530
|
-
example_group.add_explicit_type_metadata!
|
531
|
-
end
|
532
|
-
|
533
|
-
context 'when rspec-rails is loaded in the spec' do
|
534
|
-
let(:source) do
|
535
|
-
<<-END
|
536
|
-
module RSpec
|
537
|
-
module Rails
|
538
|
-
end
|
539
|
-
end
|
540
|
-
|
541
|
-
describe 'something' do
|
542
|
-
end
|
543
|
-
END
|
544
|
-
end
|
545
|
-
|
546
|
-
let(:expected_source) do
|
547
|
-
<<-END
|
548
|
-
module RSpec
|
549
|
-
module Rails
|
550
|
-
end
|
551
|
-
end
|
552
|
-
|
553
|
-
describe 'something', :type => :controller do
|
554
|
-
end
|
555
|
-
END
|
556
|
-
end
|
557
|
-
|
558
|
-
it 'adds the metadata' do
|
559
|
-
rewritten_source.should == expected_source
|
560
|
-
end
|
561
|
-
end
|
562
|
-
|
563
|
-
context 'when rspec-rails is not loaded in the spec' do
|
564
|
-
let(:source) do
|
565
|
-
<<-END
|
566
|
-
describe 'something' do
|
567
|
-
end
|
568
|
-
END
|
569
|
-
end
|
570
|
-
|
571
|
-
it 'does nothing' do
|
572
|
-
rewritten_source.should == source
|
573
|
-
end
|
574
|
-
end
|
575
|
-
end
|
576
|
-
|
577
|
-
context 'without runtime information' do
|
578
|
-
include_context 'isolated environment'
|
579
|
-
|
580
|
-
let(:source_path) { 'spec/controllers/some_spec.rb' }
|
581
|
-
|
582
|
-
let(:source) do
|
583
|
-
<<-END
|
584
|
-
module RSpec
|
585
|
-
module Rails
|
586
|
-
end
|
587
|
-
end
|
588
|
-
|
589
|
-
describe 'something' do
|
590
|
-
end
|
591
|
-
END
|
592
|
-
end
|
593
|
-
|
594
|
-
context 'when rspec-rails is specified in the Gemfile.lock' do
|
595
|
-
before do
|
596
|
-
create_file('Gemfile.lock', <<-END.strip_heredoc)
|
597
|
-
GEM
|
598
|
-
remote: https://rubygems.org/
|
599
|
-
specs:
|
600
|
-
actionpack (4.1.8)
|
601
|
-
actionview (= 4.1.8)
|
602
|
-
activesupport (= 4.1.8)
|
603
|
-
rack (~> 1.5.2)
|
604
|
-
rack-test (~> 0.6.2)
|
605
|
-
actionview (4.1.8)
|
606
|
-
activesupport (= 4.1.8)
|
607
|
-
builder (~> 3.1)
|
608
|
-
erubis (~> 2.7.0)
|
609
|
-
activemodel (4.1.8)
|
610
|
-
activesupport (= 4.1.8)
|
611
|
-
builder (~> 3.1)
|
612
|
-
activesupport (4.1.8)
|
613
|
-
i18n (~> 0.6, >= 0.6.9)
|
614
|
-
json (~> 1.7, >= 1.7.7)
|
615
|
-
minitest (~> 5.1)
|
616
|
-
thread_safe (~> 0.1)
|
617
|
-
tzinfo (~> 1.1)
|
618
|
-
builder (3.2.2)
|
619
|
-
diff-lcs (1.2.5)
|
620
|
-
erubis (2.7.0)
|
621
|
-
i18n (0.6.11)
|
622
|
-
json (1.8.1)
|
623
|
-
minitest (5.4.3)
|
624
|
-
rack (1.5.2)
|
625
|
-
rack-test (0.6.2)
|
626
|
-
rack (>= 1.0)
|
627
|
-
railties (4.1.8)
|
628
|
-
actionpack (= 4.1.8)
|
629
|
-
activesupport (= 4.1.8)
|
630
|
-
rake (>= 0.8.7)
|
631
|
-
thor (>= 0.18.1, < 2.0)
|
632
|
-
rake (10.4.2)
|
633
|
-
rspec-core (2.14.8)
|
634
|
-
rspec-expectations (2.14.5)
|
635
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
636
|
-
rspec-mocks (2.14.6)
|
637
|
-
rspec-rails (2.14.2)
|
638
|
-
actionpack (>= 3.0)
|
639
|
-
activemodel (>= 3.0)
|
640
|
-
activesupport (>= 3.0)
|
641
|
-
railties (>= 3.0)
|
642
|
-
rspec-core (~> 2.14.0)
|
643
|
-
rspec-expectations (~> 2.14.0)
|
644
|
-
rspec-mocks (~> 2.14.0)
|
645
|
-
thor (0.19.1)
|
646
|
-
thread_safe (0.3.4)
|
647
|
-
tzinfo (1.2.2)
|
648
|
-
thread_safe (~> 0.1)
|
649
|
-
|
650
|
-
PLATFORMS
|
651
|
-
ruby
|
652
|
-
|
653
|
-
DEPENDENCIES
|
654
|
-
rspec-rails (~> 2.14.0)
|
655
|
-
END
|
656
|
-
end
|
657
|
-
|
658
|
-
let(:expected_source) do
|
659
|
-
<<-END
|
660
|
-
module RSpec
|
661
|
-
module Rails
|
662
|
-
end
|
663
|
-
end
|
664
|
-
|
665
|
-
describe 'something', :type => :controller do
|
666
|
-
end
|
667
|
-
END
|
668
|
-
end
|
669
|
-
|
670
|
-
it 'adds the metadata' do
|
671
|
-
example_group.add_explicit_type_metadata!
|
672
|
-
rewritten_source.should == expected_source
|
673
|
-
end
|
674
|
-
end
|
675
|
-
|
676
|
-
context 'when rspec-rails is not specified in the Gemfile.lock' do
|
677
|
-
before do
|
678
|
-
create_file('Gemfile.lock', <<-END.strip_heredoc)
|
679
|
-
GEM
|
680
|
-
remote: https://rubygems.org/
|
681
|
-
specs:
|
682
|
-
diff-lcs (1.2.5)
|
683
|
-
rspec (2.14.1)
|
684
|
-
rspec-core (~> 2.14.0)
|
685
|
-
rspec-expectations (~> 2.14.0)
|
686
|
-
rspec-mocks (~> 2.14.0)
|
687
|
-
rspec-core (2.14.8)
|
688
|
-
rspec-expectations (2.14.5)
|
689
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
690
|
-
rspec-mocks (2.14.6)
|
691
|
-
|
692
|
-
PLATFORMS
|
693
|
-
ruby
|
694
|
-
|
695
|
-
DEPENDENCIES
|
696
|
-
rspec (~> 2.14.0)
|
697
|
-
END
|
698
|
-
end
|
699
|
-
|
700
|
-
it 'does nothing' do
|
701
|
-
example_group.add_explicit_type_metadata!
|
702
|
-
rewritten_source.should == source
|
703
|
-
end
|
704
|
-
end
|
705
|
-
|
706
|
-
context 'when there is no Gemfile.lock' do
|
707
|
-
it 'does nothing' do
|
708
|
-
example_group.add_explicit_type_metadata!
|
709
|
-
rewritten_source.should == source
|
710
|
-
end
|
711
|
-
end
|
712
|
-
end
|
713
|
-
end
|
714
|
-
end
|
715
|
-
end
|
716
|
-
end
|