transpec 1.13.1 → 2.0.0

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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGELOG.md +6 -0
  4. data/README.md +63 -22
  5. data/README.md.erb +55 -16
  6. data/lib/transpec/cli.rb +9 -9
  7. data/lib/transpec/commit_message.rb +2 -0
  8. data/lib/transpec/{configuration.rb → config.rb} +7 -6
  9. data/lib/transpec/converter.rb +57 -46
  10. data/lib/transpec/option_parser.rb +23 -25
  11. data/lib/transpec/rspec_version.rb +6 -0
  12. data/lib/transpec/spec_suite.rb +2 -6
  13. data/lib/transpec/syntax/example.rb +2 -15
  14. data/lib/transpec/syntax/example_group.rb +111 -9
  15. data/lib/transpec/syntax/have/dynamic_analysis.rb +1 -1
  16. data/lib/transpec/syntax/mixin/metadata.rb +29 -0
  17. data/lib/transpec/syntax/mixin/rspec_rails.rb +27 -0
  18. data/lib/transpec/syntax/rspec_configure.rb +14 -3
  19. data/lib/transpec/syntax/rspec_configure/{configuration_modification.rb → config_modification.rb} +18 -15
  20. data/lib/transpec/syntax/rspec_configure/framework.rb +7 -7
  21. data/lib/transpec/syntax/rspec_configure/mocks.rb +1 -1
  22. data/lib/transpec/version.rb +3 -3
  23. data/spec/transpec/commit_message_spec.rb +9 -1
  24. data/spec/transpec/{configuration_spec.rb → config_spec.rb} +19 -18
  25. data/spec/transpec/converter_spec.rb +245 -210
  26. data/spec/transpec/option_parser_spec.rb +27 -59
  27. data/spec/transpec/rspec_version_spec.rb +26 -0
  28. data/spec/transpec/syntax/example_group_spec.rb +277 -0
  29. data/spec/transpec/syntax/have_spec.rb +1 -1
  30. data/spec/transpec/syntax/rspec_configure_spec.rb +117 -0
  31. data/tasks/fixtures/guard/2.99.0/COMMIT_EDITMSG +3 -1
  32. data/tasks/fixtures/guard/3.0.0/COMMIT_EDITMSG +3 -1
  33. data/tasks/fixtures/mail/2.99.0/COMMIT_EDITMSG +3 -1
  34. data/tasks/fixtures/mail/3.0.0/COMMIT_EDITMSG +3 -1
  35. data/tasks/fixtures/twitter/2.99.0/COMMIT_EDITMSG +3 -1
  36. data/tasks/fixtures/twitter/3.0.0/COMMIT_EDITMSG +3 -1
  37. data/tasks/readme.rake +3 -2
  38. metadata +8 -6
@@ -110,7 +110,7 @@ module Transpec
110
110
 
111
111
  context 'with runtime information' do
112
112
  include_context 'dynamic analysis objects'
113
- it { should be_false }
113
+ it { should be_true }
114
114
  end
115
115
  end
116
116
 
@@ -9,6 +9,34 @@ module Transpec
9
9
  include_context 'parsed objects'
10
10
  include_context 'syntax object', RSpecConfigure, :rspec_configure
11
11
 
12
+ context 'when multiple configurations are added' do
13
+ before do
14
+ rspec_configure.expose_dsl_globally = true
15
+ rspec_configure.infer_spec_type_from_file_location!
16
+ end
17
+
18
+ let(:source) do
19
+ <<-END
20
+ RSpec.configure do |config|
21
+ end
22
+ END
23
+ end
24
+
25
+ let(:expected_source) do
26
+ <<-END
27
+ RSpec.configure do |config|
28
+ config.expose_dsl_globally = true
29
+
30
+ config.infer_spec_type_from_file_location!
31
+ end
32
+ END
33
+ end
34
+
35
+ it 'properly adds them' do
36
+ rewritten_source.should == expected_source
37
+ end
38
+ end
39
+
12
40
  describe '#expose_dsl_globally=' do
13
41
  before do
14
42
  rspec_configure.expose_dsl_globally = value
@@ -82,6 +110,95 @@ module Transpec
82
110
  end
83
111
  end
84
112
 
113
+ describe '#infer_spec_type_from_file_location!' do
114
+ before do
115
+ rspec_configure.infer_spec_type_from_file_location!
116
+ end
117
+
118
+ context 'when #infer_spec_type_from_file_location! does not exist' do
119
+ let(:source) do
120
+ <<-END
121
+ RSpec.configure do |config|
122
+ end
123
+ END
124
+ end
125
+
126
+ let(:expected_source) do
127
+ <<-END
128
+ RSpec.configure do |config|
129
+ config.infer_spec_type_from_file_location!
130
+ end
131
+ END
132
+ end
133
+
134
+ it 'adds #infer_spec_type_from_file_location! statement' do
135
+ rewritten_source.should == expected_source
136
+ end
137
+ end
138
+
139
+ context 'when #infer_spec_type_from_file_location! already exists' do
140
+ let(:source) do
141
+ <<-END
142
+ RSpec.configure do |config|
143
+ config.infer_spec_type_from_file_location!
144
+ end
145
+ END
146
+ end
147
+
148
+ it 'does nothing' do
149
+ rewritten_source.should == source
150
+ end
151
+ end
152
+
153
+ context 'with runtime information' do
154
+ include_context 'dynamic analysis objects'
155
+
156
+ context 'when rspec-rails is loaded in the spec' do
157
+ let(:source) do
158
+ <<-END
159
+ module RSpec
160
+ module Rails
161
+ end
162
+ end
163
+
164
+ RSpec.configure do |config|
165
+ end
166
+ END
167
+ end
168
+
169
+ let(:expected_source) do
170
+ <<-END
171
+ module RSpec
172
+ module Rails
173
+ end
174
+ end
175
+
176
+ RSpec.configure do |config|
177
+ config.infer_spec_type_from_file_location!
178
+ end
179
+ END
180
+ end
181
+
182
+ it 'adds #infer_spec_type_from_file_location! statement' do
183
+ rewritten_source.should == expected_source
184
+ end
185
+ end
186
+
187
+ context 'when rspec-rails is not loaded in the spec' do
188
+ let(:source) do
189
+ <<-END
190
+ RSpec.configure do |config|
191
+ end
192
+ END
193
+ end
194
+
195
+ it 'does nothing' do
196
+ rewritten_source.should == source
197
+ end
198
+ end
199
+ end
200
+ end
201
+
85
202
  shared_examples '#syntaxes' do |framework_block_method|
86
203
  describe '#syntaxes' do
87
204
  subject { super().syntaxes }
@@ -1,6 +1,6 @@
1
1
  Convert specs to RSpec 2.99.0.beta2 syntax with Transpec
2
2
 
3
- This conversion is done by Transpec 1.11.1 with the following command:
3
+ This conversion is done by Transpec 1.13.1 with the following command:
4
4
  transpec --force
5
5
 
6
6
  * 396 conversions
@@ -78,3 +78,5 @@ This conversion is done by Transpec 1.11.1 with the following command:
78
78
  * 1 conversion
79
79
  from: it { should_not ... }
80
80
  to: it { is_expected.not_to ... }
81
+
82
+ See also: https://github.com/yujinakayama/transpec#supported-conversions
@@ -1,6 +1,6 @@
1
1
  Convert specs to RSpec 3.0.0.beta2 syntax with Transpec
2
2
 
3
- This conversion is done by Transpec 1.11.1 with the following command:
3
+ This conversion is done by Transpec 1.13.1 with the following command:
4
4
  transpec --force --convert example_group,hook_scope
5
5
 
6
6
  * 31 conversions
@@ -30,3 +30,5 @@ This conversion is done by Transpec 1.11.1 with the following command:
30
30
  * 1 conversion
31
31
  from: after(:each) { }
32
32
  to: after(:example) { }
33
+
34
+ See also: https://github.com/yujinakayama/transpec#supported-conversions
@@ -1,6 +1,6 @@
1
1
  Convert specs to RSpec 2.99.0.beta2 syntax with Transpec
2
2
 
3
- This conversion is done by Transpec 1.11.1 with the following command:
3
+ This conversion is done by Transpec 1.13.1 with the following command:
4
4
  transpec --force
5
5
 
6
6
  * 2161 conversions
@@ -82,3 +82,5 @@ This conversion is done by Transpec 1.11.1 with the following command:
82
82
  * 1 conversion
83
83
  from: obj.stub!(:message)
84
84
  to: obj.stub(:message)
85
+
86
+ See also: https://github.com/yujinakayama/transpec#supported-conversions
@@ -1,6 +1,6 @@
1
1
  Convert specs to RSpec 3.0.0.beta2 syntax with Transpec
2
2
 
3
- This conversion is done by Transpec 1.11.1 with the following command:
3
+ This conversion is done by Transpec 1.13.1 with the following command:
4
4
  transpec --force --convert example_group,hook_scope
5
5
 
6
6
  * 82 conversions
@@ -26,3 +26,5 @@ This conversion is done by Transpec 1.11.1 with the following command:
26
26
  * 1 conversion
27
27
  from: obj.stub(:message => value)
28
28
  to: allow(obj).to receive_messages(:message => value)
29
+
30
+ See also: https://github.com/yujinakayama/transpec#supported-conversions
@@ -1,6 +1,6 @@
1
1
  Convert specs to RSpec 2.99.0.beta2 syntax with Transpec
2
2
 
3
- This conversion is done by Transpec 1.11.1 with the following command:
3
+ This conversion is done by Transpec 1.13.1 with the following command:
4
4
  transpec --force
5
5
 
6
6
  * 899 conversions
@@ -34,3 +34,5 @@ This conversion is done by Transpec 1.11.1 with the following command:
34
34
  * 2 conversions
35
35
  from: obj.stub!(:message)
36
36
  to: allow(obj).to receive(:message)
37
+
38
+ See also: https://github.com/yujinakayama/transpec#supported-conversions
@@ -1,6 +1,6 @@
1
1
  Convert specs to RSpec 3.0.0.beta2 syntax with Transpec
2
2
 
3
- This conversion is done by Transpec 1.11.1 with the following command:
3
+ This conversion is done by Transpec 1.13.1 with the following command:
4
4
  transpec --force --convert example_group,hook_scope
5
5
 
6
6
  * 54 conversions
@@ -14,3 +14,5 @@ This conversion is done by Transpec 1.11.1 with the following command:
14
14
  * 1 conversion
15
15
  from: before(:all) { }
16
16
  to: before(:context) { }
17
+
18
+ See also: https://github.com/yujinakayama/transpec#supported-conversions
@@ -67,9 +67,10 @@ class READMEContext
67
67
  converted_source = nil
68
68
 
69
69
  in_isolated_env do
70
- FileHelper.create_file('spec/example_spec.rb', source)
70
+ path = options[:path] || 'spec/example_spec.rb'
71
+ FileHelper.create_file(path, source)
71
72
  cli.run(cli_args)
72
- converted_source = File.read('spec/example_spec.rb')
73
+ converted_source = File.read(path)
73
74
  end
74
75
 
75
76
  converted_source = unwrap_source(converted_source, options[:wrap_with])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transpec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuji Nakayama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-07 00:00:00.000000000 Z
11
+ date: 2014-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -252,7 +252,7 @@ files:
252
252
  - lib/transpec/base_rewriter.rb
253
253
  - lib/transpec/cli.rb
254
254
  - lib/transpec/commit_message.rb
255
- - lib/transpec/configuration.rb
255
+ - lib/transpec/config.rb
256
256
  - lib/transpec/conversion_error.rb
257
257
  - lib/transpec/converter.rb
258
258
  - lib/transpec/dynamic_analyzer.rb
@@ -294,10 +294,12 @@ files:
294
294
  - lib/transpec/syntax/mixin/expectizable.rb
295
295
  - lib/transpec/syntax/mixin/matcher_owner.rb
296
296
  - lib/transpec/syntax/mixin/messaging_host.rb
297
+ - lib/transpec/syntax/mixin/metadata.rb
297
298
  - lib/transpec/syntax/mixin/monkey_patch.rb
298
299
  - lib/transpec/syntax/mixin/monkey_patch_any_instance.rb
299
300
  - lib/transpec/syntax/mixin/no_message_allowance.rb
300
301
  - lib/transpec/syntax/mixin/owned_matcher.rb
302
+ - lib/transpec/syntax/mixin/rspec_rails.rb
301
303
  - lib/transpec/syntax/mixin/send.rb
302
304
  - lib/transpec/syntax/mixin/should_base.rb
303
305
  - lib/transpec/syntax/mixin/useless_and_return.rb
@@ -307,7 +309,7 @@ files:
307
309
  - lib/transpec/syntax/raise_error.rb
308
310
  - lib/transpec/syntax/receive.rb
309
311
  - lib/transpec/syntax/rspec_configure.rb
310
- - lib/transpec/syntax/rspec_configure/configuration_modification.rb
312
+ - lib/transpec/syntax/rspec_configure/config_modification.rb
311
313
  - lib/transpec/syntax/rspec_configure/expectations.rb
312
314
  - lib/transpec/syntax/rspec_configure/framework.rb
313
315
  - lib/transpec/syntax/rspec_configure/mocks.rb
@@ -325,7 +327,7 @@ files:
325
327
  - spec/transpec/ast/node_spec.rb
326
328
  - spec/transpec/cli_spec.rb
327
329
  - spec/transpec/commit_message_spec.rb
328
- - spec/transpec/configuration_spec.rb
330
+ - spec/transpec/config_spec.rb
329
331
  - spec/transpec/converter_spec.rb
330
332
  - spec/transpec/dynamic_analyzer/rewriter_spec.rb
331
333
  - spec/transpec/dynamic_analyzer_spec.rb
@@ -411,7 +413,7 @@ test_files:
411
413
  - spec/transpec/ast/node_spec.rb
412
414
  - spec/transpec/cli_spec.rb
413
415
  - spec/transpec/commit_message_spec.rb
414
- - spec/transpec/configuration_spec.rb
416
+ - spec/transpec/config_spec.rb
415
417
  - spec/transpec/converter_spec.rb
416
418
  - spec/transpec/dynamic_analyzer/rewriter_spec.rb
417
419
  - spec/transpec/dynamic_analyzer_spec.rb