transpec 1.9.3 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.travis.yml +1 -1
  4. data/CHANGELOG.md +5 -0
  5. data/CONTRIBUTING.md +19 -0
  6. data/README.md +78 -9
  7. data/README.md.erb +68 -10
  8. data/lib/transpec/annotatable.rb +16 -0
  9. data/lib/transpec/cli.rb +35 -27
  10. data/lib/transpec/configuration.rb +1 -0
  11. data/lib/transpec/conversion_error.rb +23 -0
  12. data/lib/transpec/converter.rb +59 -50
  13. data/lib/transpec/dynamic_analyzer.rb +13 -29
  14. data/lib/transpec/dynamic_analyzer/rewriter.rb +3 -10
  15. data/lib/transpec/dynamic_analyzer/runtime_data.rb +16 -8
  16. data/lib/transpec/file_finder.rb +1 -1
  17. data/lib/transpec/git.rb +1 -1
  18. data/lib/transpec/option_parser.rb +12 -10
  19. data/lib/transpec/project.rb +3 -3
  20. data/lib/transpec/record.rb +19 -2
  21. data/lib/transpec/report.rb +29 -13
  22. data/lib/transpec/rspec_version.rb +7 -7
  23. data/lib/transpec/static_context_inspector.rb +1 -5
  24. data/lib/transpec/syntax.rb +11 -16
  25. data/lib/transpec/syntax/be_boolean.rb +1 -1
  26. data/lib/transpec/syntax/be_close.rb +1 -1
  27. data/lib/transpec/syntax/current_example.rb +88 -0
  28. data/lib/transpec/syntax/double.rb +1 -1
  29. data/lib/transpec/syntax/example.rb +60 -54
  30. data/lib/transpec/syntax/have.rb +27 -15
  31. data/lib/transpec/syntax/have/have_record.rb +12 -0
  32. data/lib/transpec/syntax/have/source_builder.rb +18 -16
  33. data/lib/transpec/syntax/its.rb +12 -11
  34. data/lib/transpec/syntax/matcher_definition.rb +1 -1
  35. data/lib/transpec/syntax/method_stub.rb +3 -7
  36. data/lib/transpec/syntax/mixin/matcher_owner.rb +2 -2
  37. data/lib/transpec/syntax/mixin/monkey_patch.rb +3 -5
  38. data/lib/transpec/syntax/mixin/monkey_patch_any_instance.rb +2 -4
  39. data/lib/transpec/syntax/mixin/owned_matcher.rb +1 -4
  40. data/lib/transpec/syntax/mixin/send.rb +7 -9
  41. data/lib/transpec/syntax/oneliner_should.rb +4 -4
  42. data/lib/transpec/syntax/operator.rb +27 -11
  43. data/lib/transpec/syntax/pending.rb +110 -0
  44. data/lib/transpec/syntax/raise_error.rb +1 -1
  45. data/lib/transpec/syntax/receive.rb +4 -4
  46. data/lib/transpec/syntax/rspec_configure/framework.rb +3 -3
  47. data/lib/transpec/syntax/should.rb +2 -2
  48. data/lib/transpec/syntax/should_receive.rb +3 -3
  49. data/lib/transpec/util.rb +38 -6
  50. data/lib/transpec/version.rb +2 -2
  51. data/spec/support/file_helper.rb +1 -1
  52. data/spec/support/shared_context.rb +3 -8
  53. data/spec/transpec/cli_spec.rb +63 -1
  54. data/spec/transpec/configuration_spec.rb +1 -0
  55. data/spec/transpec/converter_spec.rb +106 -15
  56. data/spec/transpec/dynamic_analyzer/rewriter_spec.rb +12 -52
  57. data/spec/transpec/dynamic_analyzer_spec.rb +2 -2
  58. data/spec/transpec/option_parser_spec.rb +3 -2
  59. data/spec/transpec/report_spec.rb +33 -4
  60. data/spec/transpec/rspec_version_spec.rb +5 -2
  61. data/spec/transpec/syntax/current_example_spec.rb +267 -0
  62. data/spec/transpec/syntax/example_spec.rb +156 -122
  63. data/spec/transpec/syntax/have_spec.rb +43 -32
  64. data/spec/transpec/syntax/method_stub_spec.rb +8 -0
  65. data/spec/transpec/syntax/operator_spec.rb +67 -2
  66. data/spec/transpec/syntax/pending_spec.rb +375 -0
  67. metadata +12 -4
  68. data/lib/transpec/context_error.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65c3e2a67d42f7fc8b2ca50e0853242a6057bfcb
4
- data.tar.gz: facb20a69acc7f105f48b47524e2b6486b68c1f1
3
+ metadata.gz: 6746cd9c37b13d9dcf9c77b423146988dc76fc05
4
+ data.tar.gz: 9741bc313663316ea54b25eff57abce0aa3b8440
5
5
  SHA512:
6
- metadata.gz: 7dc1164f70806bad460e845710010a9365751e02ccc106034f71d25a0d979efe8e283b0837be635385558317a988f5c71ab72c78216a3fae1ddfc6b0d93d18f2
7
- data.tar.gz: 05d9de7fa3d15cb62da0e91cfa85c71f6ad615c70452c7ddee00aa0c9cb3925a3dfe87f2b383d210adb26661ffb8134190821ddbc3e6706ae5686a8997a6c586
6
+ metadata.gz: 8794a9d4a01800a80b7a7ab09c29418d2b27a55978263d655ea7f81ac8c2e7babbdacb306caef3a1086dba283c67bb7ec81b8a48267de1b3f3758eff7be57eeb
7
+ data.tar.gz: 531aca6df23e26d22e048231c6393c044e13137d753924b568a25ee7e11a81d57271ac652c93e403001fd65cc23f79cb3de2f4710f7496fed39521b6277d10e1
@@ -54,4 +54,4 @@ BracesAroundHashParameters:
54
54
 
55
55
  # TODO: Shorten to 100.
56
56
  ClassLength:
57
- Max: 173
57
+ Max: 140
@@ -2,7 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
- - 2.1.0
5
+ - 2.1.1
6
6
  - jruby
7
7
  before_install: gem update --remote bundler
8
8
  script: bundle exec rake travis
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Development
4
4
 
5
+ ## v1.10.0
6
+
7
+ * Support conversion of pending examples
8
+ * Display cautions for less-accurate conversions caused by a lack of runtime information ([#42](https://github.com/yujinakayama/transpec/issues/42))
9
+
5
10
  ## v1.9.3
6
11
 
7
12
  * Handle `variable.any_instance` ([#46](https://github.com/yujinakayama/transpec/issues/46))
@@ -0,0 +1,19 @@
1
+ # Contributing
2
+
3
+ If you're going to report an issue or submit a pull requrest, please follow these guidelines.
4
+
5
+ ## Reporting an Issue
6
+
7
+ * Provide the problematic code or the project's URL.
8
+ * Include the version of Ruby you're using (`ruby --version`).
9
+ * Include the version of Transpec you're using (`transpec --version`).
10
+ * Include complete command-line options you passed to `transpec`.
11
+
12
+ ## Pull Requests
13
+
14
+ * Add tests for your change unless it's a refactoring.
15
+ * Run `bundle exec rake`. If any failing test or code style issue is reported, fix it.
16
+ * If you're going to modify the content of `README.md`:
17
+ * Edit `README.md.erb` instead.
18
+ * Run `bundle exec rake readme`. This will generate `README.md` from `README.md.erb`.
19
+ * Commit both files.
data/README.md CHANGED
@@ -197,7 +197,7 @@ Running dynamic analysis with command "bundle exec rspec"...
197
197
 
198
198
  ### `-s/--skip-dynamic-analysis`
199
199
 
200
- Skip dynamic analysis and convert with only static analysis. Note that specifying this option decreases the conversion accuracy.
200
+ Skip dynamic analysis and convert with only static analysis. Note that specifying this option decreases the conversion accuracy especially in the conversion of [`have(n).items` matcher](#havenitems-matcher).
201
201
 
202
202
  ### `-c/--rspec-command`
203
203
 
@@ -207,6 +207,12 @@ Transpec needs to run your specs in a copied project directory for dynamic analy
207
207
  If your project requires some special setup or commands to run specs, use this option.
208
208
  `bundle exec rspec` is used by default.
209
209
 
210
+ Note that the command to run dynamic analysis does _not_ affect to the files or specs to be converted.
211
+ This means that even if you specify a command that only runs a subset of the files in your spec suite or a subset of the specs in a file, every spec will be converted.
212
+ For this reason, it's recommended to provide a command that runs full spec suite to `-c/--rspec-command`.
213
+ If you want to convert only a subset of the files in a spec suite, pass the paths to `transpec`.
214
+ See [Advanced Usage](#advanced-usage) for more details.
215
+
210
216
  ```bash
211
217
  $ transpec --rspec-command "./special_setup.sh && bundle exec rspec"
212
218
  ```
@@ -232,6 +238,7 @@ Type | Target Syntax | Converted Syntax
232
238
  `stub` | `obj.stub(:message)` | `allow(obj).to receive(:message)`
233
239
  `have_items` | `expect(obj).to have(n).items` | `expect(obj.size).to eq(n)`
234
240
  `its` | `its(:attr) { }` | `describe '#attr' { subject { }; it { } }`
241
+ `pending` | `pending 'is an example' { }` | `skip 'is an example' { }`
235
242
  `deprecated` | All other deprecated syntaxes | Latest syntaxes
236
243
 
237
244
  See [Supported Conversions](#supported-conversions) for more details.
@@ -427,6 +434,7 @@ The one-liner (implicit receiver) `should`:
427
434
  * [Useless `and_return`](#useless-and_return)
428
435
  * [`any_instance` implementation blocks](#any_instance-implementation-blocks)
429
436
  * [Deprecated test double aliases](#deprecated-test-double-aliases)
437
+ * [Pending examples](#pending-examples)
430
438
  * [Current example object](#current-example-object)
431
439
  * [Custom matcher DSL](#custom-matcher-dsl)
432
440
 
@@ -1017,6 +1025,75 @@ double('something')
1017
1025
  * Deprecation: deprecated since RSpec 2.14, removed in RSpec 3.0
1018
1026
  * See also: [myronmarston / why_double.md - Gist](https://gist.github.com/myronmarston/6576665)
1019
1027
 
1028
+ ### Pending examples
1029
+
1030
+ **This conversion is available only if your project's RSpec is `>= 2.99.0.beta1` and `< 3.0.0.beta1`.**
1031
+
1032
+ Targets:
1033
+
1034
+ ```ruby
1035
+ describe 'example' do
1036
+ it 'is skipped', :pending => true do
1037
+ do_something_possibly_fail # This won't be run
1038
+ end
1039
+
1040
+ pending 'is skipped' do
1041
+ do_something_possibly_fail # This won't be run
1042
+ end
1043
+
1044
+ it 'is skipped' do
1045
+ pending
1046
+ do_something_possibly_fail # This won't be run
1047
+ end
1048
+
1049
+ it 'is run and expected to fail' do
1050
+ pending do
1051
+ do_something_surely_fail # This will be run and expected to fail
1052
+ end
1053
+ end
1054
+ end
1055
+ ```
1056
+
1057
+ Will be converted to:
1058
+
1059
+ ```ruby
1060
+ describe 'example' do
1061
+ it 'is skipped', :skip => true do
1062
+ do_something_possibly_fail # This won't be run
1063
+ end
1064
+
1065
+ skip 'is skipped' do
1066
+ do_something_possibly_fail # This won't be run
1067
+ end
1068
+
1069
+ it 'is skipped' do
1070
+ skip
1071
+ do_something_possibly_fail # This won't be run
1072
+ end
1073
+
1074
+ it 'is run and expected to fail' do
1075
+ pending # #pending with block is no longer supported
1076
+ do_something_surely_fail # This will be run and expected to fail
1077
+ end
1078
+ end
1079
+ ```
1080
+
1081
+ Here's an excerpt from [the warning](https://github.com/rspec/rspec-core/blob/v2.99.0.beta2/lib/rspec/core/example_group.rb#L67-L75) for pending examples in RSpec 2.99:
1082
+
1083
+ > The semantics of `RSpec::Core::ExampleGroup#pending` are changing in RSpec 3.
1084
+ > In RSpec 2.x, it caused the example to be skipped. In RSpec 3, the example will
1085
+ > still be run but is expected to fail, and will be marked as a failure (rather
1086
+ > than as pending) if the example passes, just like how `pending` with a block
1087
+ > from within an example already works.
1088
+ >
1089
+ > To keep the same skip semantics, change `pending` to `skip`. Otherwise, if you
1090
+ > want the new RSpec 3 behavior, you can safely ignore this warning and continue
1091
+ > to upgrade to RSpec 3 without addressing it.
1092
+
1093
+ * This conversion can be disabled by: `--keep pending`
1094
+ * Deprecation: not deprecated but the behavior changes in RSpec 3.0
1095
+ * See also: [Feature request: shortcut for pending-block within it · rspec/rspec-core](https://github.com/rspec/rspec-core/issues/1208)
1096
+
1020
1097
  ### Current example object
1021
1098
 
1022
1099
  **This conversion is available only if your project's RSpec is `2.99.0.beta1` or later.**
@@ -1111,14 +1188,6 @@ end
1111
1188
 
1112
1189
  Tested on MRI 1.9, 2.0, 2.1 and JRuby in 1.9 mode.
1113
1190
 
1114
- ## Contributing
1115
-
1116
- 1. Fork it
1117
- 2. Create your feature branch (`git checkout -b my-new-feature`)
1118
- 3. Commit your changes (`git commit -am 'Add some feature'`)
1119
- 4. Push to the branch (`git push origin my-new-feature`)
1120
- 5. Create new Pull Request
1121
-
1122
1191
  ## License
1123
1192
 
1124
1193
  Copyright (c) 2013 Yuji Nakayama
@@ -171,7 +171,7 @@ Running dynamic analysis with command "bundle exec rspec"...
171
171
 
172
172
  ### `-s/--skip-dynamic-analysis`
173
173
 
174
- Skip dynamic analysis and convert with only static analysis. Note that specifying this option decreases the conversion accuracy.
174
+ Skip dynamic analysis and convert with only static analysis. Note that specifying this option decreases the conversion accuracy especially in the conversion of [`have(n).items` matcher](#havenitems-matcher).
175
175
 
176
176
  ### `-c/--rspec-command`
177
177
 
@@ -181,6 +181,12 @@ Transpec needs to run your specs in a copied project directory for dynamic analy
181
181
  If your project requires some special setup or commands to run specs, use this option.
182
182
  `bundle exec rspec` is used by default.
183
183
 
184
+ Note that the command to run dynamic analysis does _not_ affect to the files or specs to be converted.
185
+ This means that even if you specify a command that only runs a subset of the files in your spec suite or a subset of the specs in a file, every spec will be converted.
186
+ For this reason, it's recommended to provide a command that runs full spec suite to `-c/--rspec-command`.
187
+ If you want to convert only a subset of the files in a spec suite, pass the paths to `transpec`.
188
+ See [Advanced Usage](#advanced-usage) for more details.
189
+
184
190
  ```bash
185
191
  $ transpec --rspec-command "./special_setup.sh && bundle exec rspec"
186
192
  ```
@@ -208,6 +214,7 @@ conversion_type_table = <<END
208
214
  `stub` | `obj.stub(:message)` | `allow(obj).to receive(:message)`
209
215
  `have_items` | `expect(obj).to have(n).items` | `expect(obj.size).to eq(n)`
210
216
  `its` | `its(:attr) { }` | `describe '#attr' { subject { }; it { } }`
217
+ `pending` | `pending 'is an example' { }` | `skip 'is an example' { }`
211
218
  `deprecated` | All other deprecated syntaxes | Latest syntaxes
212
219
  END
213
220
 
@@ -886,7 +893,7 @@ Will be converted to:
886
893
 
887
894
  ### `any_instance` implementation blocks
888
895
 
889
- **This conversion is available only if your project's RSpec is `>= <%= Transpec::RSpecVersion::ANY_INSTANCE_IMPLEMENTATION_BLOCK_MIGRATION_BEGIN %>` and `< <%= Transpec::RSpecVersion::ANY_INSTANCE_IMPLEMENTATION_BLOCK_MIGRATION_EXCLUSIVE_END %>`.**
896
+ **This conversion is available only if your project's RSpec is `>= <%= Transpec::RSpecVersion::RSPEC_2_99 %>` and `< <%= Transpec::RSpecVersion::RSPEC_3_0 %>`.**
890
897
 
891
898
  Targets:
892
899
 
@@ -967,6 +974,65 @@ double('something')
967
974
  * Deprecation: deprecated since RSpec 2.14, removed in RSpec 3.0
968
975
  * See also: [myronmarston / why_double.md - Gist](https://gist.github.com/myronmarston/6576665)
969
976
 
977
+ ### Pending examples
978
+
979
+ **This conversion is available only if your project's RSpec is `>= <%= Transpec::RSpecVersion::RSPEC_2_99 %>` and `< <%= Transpec::RSpecVersion::RSPEC_3_0 %>`.**
980
+
981
+ Targets:
982
+
983
+ ```ruby
984
+ <%=
985
+ pending_example_target = <<END
986
+ describe 'example' do
987
+ it 'is skipped', :pending => true do
988
+ do_something_possibly_fail # This won't be run
989
+ end
990
+
991
+ pending 'is skipped' do
992
+ do_something_possibly_fail # This won't be run
993
+ end
994
+
995
+ it 'is skipped' do
996
+ pending
997
+ do_something_possibly_fail # This won't be run
998
+ end
999
+
1000
+ it 'is run and expected to fail' do
1001
+ pending do
1002
+ do_something_surely_fail # This will be run and expected to fail
1003
+ end
1004
+ end
1005
+ end
1006
+ END
1007
+ -%>
1008
+ ```
1009
+
1010
+ Will be converted to:
1011
+
1012
+ ```ruby
1013
+ <%=
1014
+ rspec_version = Transpec::RSpecVersion.skip_available_version
1015
+ Transpec::Converter.new(nil, rspec_version).convert(pending_example_target)
1016
+ .gsub('pending', 'pending # #pending with block is no longer supported')
1017
+ -%>
1018
+ ```
1019
+
1020
+ Here's an excerpt from [the warning](https://github.com/rspec/rspec-core/blob/v2.99.0.beta2/lib/rspec/core/example_group.rb#L67-L75) for pending examples in RSpec 2.99:
1021
+
1022
+ > The semantics of `RSpec::Core::ExampleGroup#pending` are changing in RSpec 3.
1023
+ > In RSpec 2.x, it caused the example to be skipped. In RSpec 3, the example will
1024
+ > still be run but is expected to fail, and will be marked as a failure (rather
1025
+ > than as pending) if the example passes, just like how `pending` with a block
1026
+ > from within an example already works.
1027
+ >
1028
+ > To keep the same skip semantics, change `pending` to `skip`. Otherwise, if you
1029
+ > want the new RSpec 3 behavior, you can safely ignore this warning and continue
1030
+ > to upgrade to RSpec 3 without addressing it.
1031
+
1032
+ * This conversion can be disabled by: `--keep pending`
1033
+ * Deprecation: not deprecated but the behavior changes in RSpec 3.0
1034
+ * See also: [Feature request: shortcut for pending-block within it · rspec/rspec-core](https://github.com/rspec/rspec-core/issues/1208)
1035
+
970
1036
  ### Current example object
971
1037
 
972
1038
  **This conversion is available only if your project's RSpec is `<%= Transpec::RSpecVersion.yielded_example_available_version %>` or later.**
@@ -1058,14 +1124,6 @@ Transpec::Converter.new(nil, rspec_version).convert(custom_matcher_dsl_target)
1058
1124
 
1059
1125
  Tested on MRI 1.9, 2.0, 2.1 and JRuby in 1.9 mode.
1060
1126
 
1061
- ## Contributing
1062
-
1063
- 1. Fork it
1064
- 2. Create your feature branch (`git checkout -b my-new-feature`)
1065
- 3. Commit your changes (`git commit -am 'Add some feature'`)
1066
- 4. Push to the branch (`git push origin my-new-feature`)
1067
- 5. Create new Pull Request
1068
-
1069
1127
  ## License
1070
1128
 
1071
1129
  Copyright (c) 2013 Yuji Nakayama
@@ -0,0 +1,16 @@
1
+ # coding: utf-8
2
+
3
+ module Transpec
4
+ module Annotatable
5
+ attr_reader :message, :source_range
6
+
7
+ def initialize(message, source_range)
8
+ @message = message
9
+ @source_range = source_range
10
+ end
11
+
12
+ def source_buffer
13
+ source_range.source_buffer
14
+ end
15
+ end
16
+ end
@@ -27,7 +27,7 @@ module Transpec
27
27
 
28
28
  def run(args)
29
29
  begin
30
- paths = OptionParser.new(@configuration).parse(args)
30
+ paths = OptionParser.new(configuration).parse(args)
31
31
  fail_if_should_not_continue!
32
32
  rescue => error
33
33
  warn error.message
@@ -46,9 +46,9 @@ module Transpec
46
46
  def process(paths)
47
47
  runtime_data = nil
48
48
 
49
- unless @configuration.skip_dynamic_analysis?
49
+ unless configuration.skip_dynamic_analysis?
50
50
  puts 'Copying the project for dynamic analysis...'
51
- DynamicAnalyzer.new(rspec_command: @configuration.rspec_command) do |analyzer|
51
+ DynamicAnalyzer.new(rspec_command: configuration.rspec_command) do |analyzer|
52
52
  puts "Running dynamic analysis with command #{analyzer.rspec_command.inspect}..."
53
53
  runtime_data = analyzer.analyze(paths)
54
54
  end
@@ -63,52 +63,49 @@ module Transpec
63
63
  def convert_file(file_path, runtime_data = nil)
64
64
  puts "Converting #{file_path}"
65
65
 
66
- converter = Converter.new(@configuration, @project.rspec_version, runtime_data, @report)
66
+ converter = Converter.new(configuration, project.rspec_version, runtime_data)
67
67
  converter.convert_file!(file_path)
68
68
 
69
- @report.context_errors.concat(converter.context_errors)
70
-
71
- converter.context_errors.each do |error|
72
- warn_invalid_context_error(error)
73
- end
69
+ warn_annotations(converter.report)
70
+ report << converter.report
74
71
  rescue Parser::SyntaxError => error
75
- @report.syntax_errors << error
72
+ report.syntax_errors << error
76
73
  warn_syntax_error(error)
77
74
  end
78
75
 
79
76
  private
80
77
 
81
78
  def fail_if_should_not_continue!
82
- unless @configuration.forced?
79
+ unless configuration.forced?
83
80
  if Git.command_available? && Git.inside_of_repository? && !Git.clean?
84
81
  fail 'The current Git repository is not clean. Aborting.'
85
82
  end
86
83
  end
87
84
 
88
- if @project.rspec_version < Transpec.required_rspec_version
85
+ if project.rspec_version < Transpec.required_rspec_version
89
86
  fail "Your project must have rspec gem dependency #{Transpec.required_rspec_version} " +
90
- "or later but currently it's #{@project.rspec_version}. Aborting."
87
+ "or later but currently it's #{project.rspec_version}. Aborting."
91
88
  end
92
89
  end
93
90
 
94
91
  def display_summary
95
92
  puts
96
93
 
97
- unless @report.records.empty?
94
+ unless report.records.empty?
98
95
  puts 'Summary:'
99
96
  puts
100
- puts @report.colored_summary
97
+ puts report.colored_summary
101
98
  puts
102
99
  end
103
100
 
104
- puts @report.colored_stats
101
+ puts report.colored_stats
105
102
  end
106
103
 
107
104
  def generate_commit_message
108
- return if @report.records.empty?
105
+ return if report.records.empty?
109
106
  return unless Git.command_available? && Git.inside_of_repository?
110
107
 
111
- commit_message = CommitMessage.new(@report, @project.rspec_version, ARGV)
108
+ commit_message = CommitMessage.new(report, project.rspec_version, ARGV)
112
109
  Git.write_commit_message(commit_message.to_s)
113
110
 
114
111
  puts
@@ -119,7 +116,7 @@ module Transpec
119
116
  end
120
117
 
121
118
  def display_final_guide
122
- return if @report.records.empty?
119
+ return if report.records.empty?
123
120
 
124
121
  puts
125
122
  puts "Done! Now run #{'rspec'.bright} and check if everything is green."
@@ -129,19 +126,30 @@ module Transpec
129
126
  warn "Syntax error at #{error.diagnostic.location}. Skipping the file.".color(:red)
130
127
  end
131
128
 
132
- def warn_invalid_context_error(error)
133
- message = error.message.color(:yellow) + $RS
134
- message << highlighted_source(error)
129
+ def warn_annotations(report)
130
+ annotations = report.records.map(&:annotation).compact
131
+ annotations.concat(report.conversion_errors)
132
+ annotations.sort_by! { |a| a.source_range.line }
133
+
134
+ annotations.each do |annotation|
135
+ warn_annotation(annotation)
136
+ end
137
+ end
138
+
139
+ def warn_annotation(annotation)
140
+ color = annotation.is_a?(Annotation) ? :yellow : :magenta
141
+ message = annotation.message.color(color) + $RS
142
+ message << highlighted_source(annotation)
135
143
  warn message
136
144
  end
137
145
 
138
- def highlighted_source(error)
139
- filename = error.source_buffer.name.color(:cyan)
146
+ def highlighted_source(annotation)
147
+ filename = annotation.source_buffer.name.color(:cyan)
140
148
 
141
- line_number = error.source_range.line
149
+ line_number = annotation.source_range.line
142
150
 
143
- source = error.source_range.source_line
144
- highlight_range = error.source_range.column_range
151
+ source = annotation.source_range.source_line
152
+ highlight_range = annotation.source_range.column_range
145
153
  source[highlight_range] = source[highlight_range].underline
146
154
 
147
155
  [filename, line_number, source].join(':')