transpec 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +8 -13
- data/CHANGELOG.md +6 -0
- data/Gemfile +3 -9
- data/README.md +8 -12
- data/README.md.erb +4 -16
- data/Rakefile +1 -2
- data/lib/transpec/base_rewriter.rb +18 -9
- data/lib/transpec/dynamic_analyzer/rewriter.rb +5 -7
- data/lib/transpec/syntax.rb +6 -2
- data/lib/transpec/syntax/its.rb +1 -2
- data/lib/transpec/syntax/mixin/expectizable.rb +1 -2
- data/lib/transpec/version.rb +1 -1
- data/tasks/ci.rake +3 -3
- data/tasks/readme.rake +147 -100
- data/transpec.gemspec +2 -2
- metadata +6 -7
- data/tasks/test.rake +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5f050e81b8e897c4e35a682c4ac792a6cfc66eae45e91c36cc7e2fd937fa6562
|
4
|
+
data.tar.gz: 03210bb216919ec7481a66401aba1c85a5f46d6c5ea13160d2b396741b7ace91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1de6e9796ab5f7e9b53099f070d5a76a2fd9c23f249e01b4e2992c0a97e8cba81d3a6af3d7e2db748bdf9e9b8ff053ed6a7327903bbbea9f4d9f889b69f2f4e1
|
7
|
+
data.tar.gz: a1a5db78f94f4cff4f952c123cda966a43c284311ce3aac7b60f190b9e5e9b6576c71ae75315c62d3c1467bec46ec902d64e10f38cde3fdad272df9755df8689
|
data/.travis.yml
CHANGED
@@ -1,26 +1,21 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 1.9.3
|
4
3
|
- 2.0.0
|
5
4
|
- 2.1.10
|
6
|
-
- 2.2.
|
7
|
-
- 2.3.
|
8
|
-
- 2.4.
|
9
|
-
-
|
10
|
-
- jruby-
|
11
|
-
- jruby-9.1.7.0
|
5
|
+
- 2.2.10
|
6
|
+
- 2.3.7
|
7
|
+
- 2.4.4
|
8
|
+
- 2.5.1
|
9
|
+
- jruby-9.2.0.0
|
12
10
|
env:
|
13
11
|
- RSPEC_VERSION=2.14
|
14
12
|
- RSPEC_VERSION=2.99
|
15
13
|
- RSPEC_VERSION=3.0
|
16
|
-
- RSPEC_VERSION=3.
|
14
|
+
- RSPEC_VERSION=3.8
|
17
15
|
- RSPEC_VERSION=master
|
18
|
-
|
19
|
-
|
20
|
-
- rvm: ruby-head
|
16
|
+
sudo: false
|
17
|
+
cache: bundler
|
21
18
|
before_install:
|
22
19
|
- gem update --system # https://github.com/sickill/rainbow/issues/49
|
23
20
|
- gem update --remote bundler
|
24
21
|
script: bundle exec rake ci
|
25
|
-
sudo: false
|
26
|
-
cache: bundler
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## Development
|
4
4
|
|
5
|
+
## v3.4.0
|
6
|
+
|
7
|
+
* Drop support for Ruby 1.9.3.
|
8
|
+
* Use `parser` gem 2.5.0.0 or later.
|
9
|
+
* Handle deprecation message `Parser::Source::Rewriter is deprecated.` from `parser` gem.
|
10
|
+
|
5
11
|
## v3.3.0
|
6
12
|
|
7
13
|
* Support `json` gem 2.x and `activesupport` gem 5.x.
|
data/Gemfile
CHANGED
@@ -2,6 +2,8 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
+
gem 'activesupport', '< 5.0' if RUBY_VERSION < '2.2'
|
6
|
+
|
5
7
|
group :development, :test do
|
6
8
|
rspec_version = ENV['RSPEC_VERSION'] || '2.14'
|
7
9
|
|
@@ -18,15 +20,7 @@ group :development, :test do
|
|
18
20
|
# https://github.com/rspec/rspec-core/pull/2197
|
19
21
|
gem 'rake', '~> 11.0'
|
20
22
|
gem 'simplecov', '~> 0.7'
|
21
|
-
gem 'rubocop', '~> 0.
|
22
|
-
end
|
23
|
-
|
24
|
-
group :development do
|
25
|
-
gem 'fuubar', '>= 1.3', '< 3.0'
|
26
|
-
gem 'guard-rspec', '>= 4.2.3', '< 5.0'
|
27
|
-
gem 'guard-rubocop', '~> 1.0'
|
28
|
-
gem 'guard-shell', '~> 0.5'
|
29
|
-
gem 'ruby_gntp', '~> 0.3'
|
23
|
+
gem 'rubocop', '~> 0.47.1'
|
30
24
|
end
|
31
25
|
|
32
26
|
group :test do
|
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/transpec.svg)](http://badge.fury.io/rb/transpec)
|
2
|
-
[![Dependency Status](https://gemnasium.com/yujinakayama/transpec.svg)](https://gemnasium.com/yujinakayama/transpec)
|
3
2
|
[![Build Status](https://travis-ci.org/yujinakayama/transpec.svg?branch=master&style=flat)](https://travis-ci.org/yujinakayama/transpec)
|
4
3
|
[![Coverage Status](https://coveralls.io/repos/yujinakayama/transpec/badge.svg?branch=master&service=github)](https://coveralls.io/github/yujinakayama/transpec?branch=master)
|
5
4
|
[![Code Climate](https://codeclimate.com/github/yujinakayama/transpec/badges/gpa.svg)](https://codeclimate.com/github/yujinakayama/transpec)
|
@@ -1451,19 +1450,16 @@ end
|
|
1451
1450
|
|
1452
1451
|
Transpec is tested on the following Ruby implementations:
|
1453
1452
|
|
1454
|
-
* MRI
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
* JRuby
|
1462
|
-
* 1.9 mode
|
1463
|
-
* 9.1.7.0
|
1453
|
+
* MRI 2.0.0
|
1454
|
+
* MRI 2.1.10
|
1455
|
+
* MRI 2.2.10
|
1456
|
+
* MRI 2.3.7
|
1457
|
+
* MRI 2.4.4
|
1458
|
+
* MRI 2.5.1
|
1459
|
+
* JRuby 9.2.0.0
|
1464
1460
|
|
1465
1461
|
## License
|
1466
1462
|
|
1467
|
-
Copyright (c) 2013–
|
1463
|
+
Copyright (c) 2013–2018 Yuji Nakayama
|
1468
1464
|
|
1469
1465
|
See the [LICENSE.txt](LICENSE.txt) for details.
|
data/README.md.erb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/transpec.svg)](http://badge.fury.io/rb/transpec)
|
2
|
-
[![Dependency Status](https://gemnasium.com/yujinakayama/transpec.svg)](https://gemnasium.com/yujinakayama/transpec)
|
3
2
|
[![Build Status](https://travis-ci.org/yujinakayama/transpec.svg?branch=master&style=flat)](https://travis-ci.org/yujinakayama/transpec)
|
4
3
|
[![Coverage Status](https://coveralls.io/repos/yujinakayama/transpec/badge.svg?branch=master&service=github)](https://coveralls.io/github/yujinakayama/transpec?branch=master)
|
5
4
|
[![Code Climate](https://codeclimate.com/github/yujinakayama/transpec/badges/gpa.svg)](https://codeclimate.com/github/yujinakayama/transpec)
|
@@ -457,8 +456,8 @@ The one-liner (implicit receiver) `should`:
|
|
457
456
|
## Supported Conversions
|
458
457
|
|
459
458
|
<%=
|
460
|
-
supported_conversions_section =
|
461
|
-
table_of_contents(supported_conversions_section, 3)
|
459
|
+
supported_conversions_section = find_section('Supported Conversions', level: 2)
|
460
|
+
table_of_contents(supported_conversions_section, level: 3)
|
462
461
|
%>
|
463
462
|
|
464
463
|
### Standard expectations
|
@@ -1472,21 +1471,10 @@ Will be converted to:
|
|
1472
1471
|
|
1473
1472
|
Transpec is tested on the following Ruby implementations:
|
1474
1473
|
|
1475
|
-
*
|
1476
|
-
<%= travis_config['rvm'].grep(/\A\d/).map { |version| " * #{version}" }.join("\n") %>
|
1477
|
-
* JRuby
|
1478
|
-
<%=
|
1479
|
-
travis_config['rvm'].grep(/\Ajruby-/).map do |name|
|
1480
|
-
version = name.sub('jruby-', '')
|
1481
|
-
if /\A(?<major>\d)(?<minor>\d)mode\z/ =~ version
|
1482
|
-
version = "#{major}.#{minor} mode"
|
1483
|
-
end
|
1484
|
-
" * #{version}"
|
1485
|
-
end.join("\n")
|
1486
|
-
%>
|
1474
|
+
<%= supported_ruby_names.map { |name| "* #{name}" }.join("\n") %>
|
1487
1475
|
|
1488
1476
|
## License
|
1489
1477
|
|
1490
|
-
Copyright (c) 2013–<%=
|
1478
|
+
Copyright (c) 2013–<%= Time.now.year %> Yuji Nakayama
|
1491
1479
|
|
1492
1480
|
See the [LICENSE.txt](LICENSE.txt) for details.
|
data/Rakefile
CHANGED
@@ -4,6 +4,23 @@ require 'transpec/processed_source'
|
|
4
4
|
|
5
5
|
module Transpec
|
6
6
|
class BaseRewriter
|
7
|
+
def self.create_source_rewriter(processed_source)
|
8
|
+
# We prefer :warn diagnostic level and diagnostic consumer over :raise level
|
9
|
+
# because the Parser::ClobberingError raised with :raise does not contain detailed message.
|
10
|
+
# https://github.com/whitequark/parser/blob/v2.5.1.2/lib/parser/source/tree_rewriter.rb#L297
|
11
|
+
source_rewriter = Parser::Source::TreeRewriter.new(
|
12
|
+
processed_source.buffer,
|
13
|
+
different_replacements: :warn,
|
14
|
+
swallowed_insertions: :warn
|
15
|
+
)
|
16
|
+
|
17
|
+
source_rewriter.diagnostics.consumer = proc do |diagnostic|
|
18
|
+
fail OverlappedRewriteError, diagnostic.render.join("\n")
|
19
|
+
end
|
20
|
+
|
21
|
+
source_rewriter
|
22
|
+
end
|
23
|
+
|
7
24
|
def rewrite_file!(arg)
|
8
25
|
processed_source = case arg
|
9
26
|
when String then ProcessedSource.from_file(arg)
|
@@ -26,7 +43,7 @@ module Transpec
|
|
26
43
|
def rewrite(processed_source)
|
27
44
|
fail processed_source.error if processed_source.error
|
28
45
|
|
29
|
-
source_rewriter = create_source_rewriter(processed_source)
|
46
|
+
source_rewriter = self.class.create_source_rewriter(processed_source)
|
30
47
|
incomplete = false
|
31
48
|
|
32
49
|
begin
|
@@ -43,14 +60,6 @@ module Transpec
|
|
43
60
|
|
44
61
|
private
|
45
62
|
|
46
|
-
def create_source_rewriter(processed_source)
|
47
|
-
Parser::Source::Rewriter.new(processed_source.buffer).tap do |source_rewriter|
|
48
|
-
source_rewriter.diagnostics.consumer = proc do
|
49
|
-
fail OverlappedRewriteError
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
63
|
def process(ast, source_rewriter) # rubocop:disable UnusedMethodArgument
|
55
64
|
fail NotImplementedError
|
56
65
|
end
|
@@ -69,22 +69,20 @@ module Transpec
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def inject_analysis_code(node, analysis_codes, source_rewriter)
|
72
|
-
front, rear = build_wrapper_codes(node, analysis_codes)
|
73
|
-
|
74
72
|
source_range = if (block_node = block_node_taken_by_method(node))
|
75
73
|
block_node.loc.expression
|
76
74
|
else
|
77
75
|
node.loc.expression
|
78
76
|
end
|
79
77
|
|
80
|
-
|
81
|
-
source_rewriter.
|
78
|
+
forward, backward = build_wrapper_codes(node, analysis_codes)
|
79
|
+
source_rewriter.wrap(source_range, forward, backward)
|
82
80
|
end
|
83
81
|
|
84
82
|
def build_wrapper_codes(node, analysis_codes)
|
85
|
-
|
86
|
-
|
87
|
-
[
|
83
|
+
forward = "#{ANALYSIS_MODULE}.#{ANALYSIS_METHOD}(("
|
84
|
+
backward = format('), self, %s, %s)', node_id(node).inspect, hash_literal(analysis_codes))
|
85
|
+
[forward, backward]
|
88
86
|
end
|
89
87
|
|
90
88
|
# Hash#inspect generates invalid literal with following example:
|
data/lib/transpec/syntax.rb
CHANGED
@@ -105,16 +105,20 @@ module Transpec
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def insert_before(range, content)
|
108
|
-
source_rewriter.
|
108
|
+
source_rewriter.insert_before(range, content)
|
109
109
|
end
|
110
110
|
|
111
111
|
def insert_after(range, content)
|
112
|
-
source_rewriter.
|
112
|
+
source_rewriter.insert_after(range, content)
|
113
113
|
end
|
114
114
|
|
115
115
|
def replace(range, content)
|
116
116
|
source_rewriter.replace(range, content)
|
117
117
|
end
|
118
|
+
|
119
|
+
def wrap(range, forward_content, backward_content)
|
120
|
+
source_rewriter.wrap(range, forward_content, backward_content)
|
121
|
+
end
|
118
122
|
end
|
119
123
|
end
|
120
124
|
end
|
data/lib/transpec/syntax/its.rb
CHANGED
@@ -26,8 +26,7 @@ module Transpec
|
|
26
26
|
|
27
27
|
def convert_to_describe_subject_it!
|
28
28
|
insert_before(beginning_of_line_range(block_node), front_code)
|
29
|
-
|
30
|
-
replace(range_from_its_to_front_of_block, 'it ')
|
29
|
+
replace(range_from_its_to_front_of_block, additional_indentation_for_it + 'it ')
|
31
30
|
insert_after(block_node.loc.expression, rear_code)
|
32
31
|
|
33
32
|
increment_block_base_indentation!
|
@@ -19,8 +19,7 @@ module Transpec
|
|
19
19
|
if Util.in_explicit_parentheses?(subject_node)
|
20
20
|
insert_before(subject_range, method)
|
21
21
|
else
|
22
|
-
|
23
|
-
insert_after(subject_range, ')')
|
22
|
+
wrap(subject_range, "#{method}(", ')')
|
24
23
|
end
|
25
24
|
end
|
26
25
|
end
|
data/lib/transpec/version.rb
CHANGED
data/tasks/ci.rake
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
tasks =
|
3
|
+
tasks = ['spec']
|
4
4
|
|
5
5
|
if RSpec::Core::Version::STRING.start_with?('2.14') && RUBY_ENGINE != 'jruby'
|
6
|
-
tasks << 'style'
|
7
|
-
tasks
|
6
|
+
tasks << 'style'
|
7
|
+
tasks << 'readme:check'
|
8
8
|
end
|
9
9
|
|
10
10
|
task ci: tasks
|
data/tasks/readme.rake
CHANGED
@@ -41,157 +41,204 @@ class READMEContext
|
|
41
41
|
|
42
42
|
def initialize(readme)
|
43
43
|
@readme = readme
|
44
|
-
require 'transpec/cli'
|
45
|
-
require 'stringio'
|
46
|
-
require 'tmpdir'
|
47
|
-
require 'rspec/mocks/standalone'
|
48
|
-
require File.join(Transpec.root, 'spec/support/file_helper')
|
49
44
|
end
|
50
45
|
|
51
46
|
def binding
|
52
47
|
super
|
53
48
|
end
|
54
49
|
|
55
|
-
|
56
|
-
|
57
|
-
|
50
|
+
module SourceConversion
|
51
|
+
def convert(source, options = {}) # rubocop:disable MethodLength
|
52
|
+
require 'transpec/cli'
|
53
|
+
require File.join(Transpec.root, 'spec/support/file_helper')
|
58
54
|
|
59
|
-
|
60
|
-
|
61
|
-
hidden_code += "\n"
|
62
|
-
source = hidden_code + source
|
63
|
-
end
|
55
|
+
cli_args = Array(options[:cli])
|
56
|
+
cli_args << '--skip-dynamic-analysis' unless options[:dynamic] # For performance
|
64
57
|
|
65
|
-
|
58
|
+
hidden_code = options[:hidden]
|
59
|
+
if hidden_code
|
60
|
+
hidden_code += "\n"
|
61
|
+
source = hidden_code + source
|
62
|
+
end
|
66
63
|
|
67
|
-
|
64
|
+
source = wrap_source(source, options[:wrap_with])
|
68
65
|
|
69
|
-
|
70
|
-
path = options[:path] || 'spec/example_spec.rb'
|
71
|
-
FileHelper.create_file(path, source)
|
66
|
+
converted_source = nil
|
72
67
|
|
73
|
-
|
68
|
+
in_isolated_env do
|
69
|
+
path = options[:path] || 'spec/example_spec.rb'
|
70
|
+
FileHelper.create_file(path, source)
|
74
71
|
|
75
|
-
|
76
|
-
cli.project.stub(:rspec_version).and_return(options[:rspec_version])
|
77
|
-
end
|
72
|
+
cli = Transpec::CLI.new
|
78
73
|
|
79
|
-
|
80
|
-
|
81
|
-
|
74
|
+
if options[:rspec_version]
|
75
|
+
cli.project.define_singleton_method(:rspec_version) { options[:rspec_version] }
|
76
|
+
end
|
77
|
+
|
78
|
+
if options[:rails]
|
79
|
+
cli.project.define_singleton_method(:depend_on_rspec_rails?) { true }
|
80
|
+
end
|
82
81
|
|
83
|
-
|
82
|
+
cli.run(cli_args)
|
84
83
|
|
85
|
-
|
84
|
+
converted_source = File.read(path)
|
85
|
+
end
|
86
|
+
|
87
|
+
converted_source = unwrap_source(converted_source, options[:wrap_with])
|
88
|
+
converted_source = converted_source[hidden_code.length..-1] if hidden_code
|
89
|
+
converted_source
|
86
90
|
end
|
87
91
|
|
88
|
-
|
89
|
-
|
90
|
-
converted_source
|
91
|
-
end
|
92
|
+
def wrap_source(source, wrapper)
|
93
|
+
source = "it 'is example' do\n" + source + "end\n" if wrapper == :example
|
92
94
|
|
93
|
-
|
94
|
-
|
95
|
+
if [:example, :group].include?(wrapper)
|
96
|
+
source = "describe 'example group' do\n" + source + "end\n"
|
97
|
+
end
|
95
98
|
|
96
|
-
|
97
|
-
source = "describe 'example group' do\n" + source + "end\n"
|
99
|
+
source
|
98
100
|
end
|
99
101
|
|
100
|
-
source
|
101
|
-
|
102
|
+
def unwrap_source(source, wrapper)
|
103
|
+
return source unless wrapper
|
102
104
|
|
103
|
-
|
104
|
-
|
105
|
+
unwrap_count = case wrapper
|
106
|
+
when :group then 1
|
107
|
+
when :example then 2
|
108
|
+
end
|
105
109
|
|
106
|
-
|
107
|
-
when :group then 1
|
108
|
-
when :example then 2
|
109
|
-
end
|
110
|
+
lines = source.lines.to_a
|
110
111
|
|
111
|
-
|
112
|
+
unwrap_count.times do
|
113
|
+
lines = lines[1..-2]
|
114
|
+
end
|
112
115
|
|
113
|
-
|
114
|
-
lines = lines[1..-2]
|
116
|
+
lines.join('')
|
115
117
|
end
|
116
118
|
|
117
|
-
|
118
|
-
|
119
|
+
def in_isolated_env
|
120
|
+
require 'stringio'
|
121
|
+
require 'tmpdir'
|
119
122
|
|
120
|
-
|
121
|
-
|
122
|
-
$stdout = StringIO.new
|
123
|
+
original_stdout = $stdout
|
124
|
+
$stdout = StringIO.new
|
123
125
|
|
124
|
-
|
125
|
-
|
126
|
-
|
126
|
+
Dir.mktmpdir do |tmpdir|
|
127
|
+
Dir.chdir(tmpdir) do
|
128
|
+
yield
|
129
|
+
end
|
127
130
|
end
|
131
|
+
ensure
|
132
|
+
$stdout = original_stdout
|
128
133
|
end
|
129
|
-
ensure
|
130
|
-
$stdout = original_stdout
|
131
134
|
end
|
132
135
|
|
133
|
-
|
134
|
-
header_pattern = pattern_for_header_level(header_level)
|
135
|
-
sections = content.each_line.slice_before(header_pattern)
|
136
|
+
include SourceConversion
|
136
137
|
|
137
|
-
|
138
|
-
|
139
|
-
|
138
|
+
module MarkdownHelper
|
139
|
+
def find_section(section_name, options = {})
|
140
|
+
header_pattern = pattern_for_header_level(options[:level])
|
141
|
+
sections = readme.each_line.slice_before(header_pattern)
|
142
|
+
|
143
|
+
sections.find do |section|
|
144
|
+
header_line = section.first
|
145
|
+
header_line.include?(section_name)
|
146
|
+
end
|
140
147
|
end
|
141
|
-
end
|
142
148
|
|
143
|
-
|
144
|
-
|
149
|
+
def table_of_contents(lines, options = {})
|
150
|
+
header_pattern = pattern_for_header_level(options[:level])
|
145
151
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
152
|
+
titles = lines.map do |line|
|
153
|
+
next unless line.match(header_pattern)
|
154
|
+
line.sub(/^[#\s]*/, '').chomp
|
155
|
+
end.compact
|
150
156
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
157
|
+
titles.map do |title|
|
158
|
+
anchor = '#' + title.gsub(/[^\w_\- ]/, '').downcase.tr(' ', '-')
|
159
|
+
"* [#{title}](#{anchor})"
|
160
|
+
end.join("\n")
|
161
|
+
end
|
156
162
|
|
157
|
-
|
158
|
-
|
163
|
+
def pattern_for_header_level(level)
|
164
|
+
/^#{'#' * level}[^#]/
|
165
|
+
end
|
159
166
|
end
|
160
167
|
|
161
|
-
|
162
|
-
types_in_doc = markdown_table.lines.map do |line|
|
163
|
-
first_column = line.split('|').first
|
164
|
-
first_column.gsub(/[^\w]/, '').to_sym
|
165
|
-
end.sort
|
168
|
+
include MarkdownHelper
|
166
169
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
+
module SyntaxTypeTableHelper
|
171
|
+
def validate_syntax_type_table(markdown_table, enabled_by_default)
|
172
|
+
types_in_doc = markdown_table.lines.map do |line|
|
173
|
+
first_column = line.split('|').first
|
174
|
+
first_column.gsub(/[^\w]/, '').to_sym
|
175
|
+
end.sort
|
170
176
|
|
171
|
-
|
172
|
-
|
173
|
-
|
177
|
+
types_in_code = Transpec::Config::DEFAULT_CONVERSIONS.select do |_type, enabled|
|
178
|
+
enabled == enabled_by_default
|
179
|
+
end.keys.sort
|
180
|
+
|
181
|
+
unless types_in_doc == types_in_code
|
182
|
+
types_missing_description = types_in_code - types_in_doc
|
183
|
+
fail "No descriptions for syntax types #{types_missing_description}"
|
184
|
+
end
|
174
185
|
end
|
175
186
|
end
|
176
187
|
|
177
|
-
|
178
|
-
|
188
|
+
include SyntaxTypeTableHelper
|
189
|
+
|
190
|
+
module CodeExampleHelper
|
191
|
+
def insert_comment_above(code, pattern, comments)
|
192
|
+
regexp = Regexp.new('^([ \t]*).*' + Regexp.escape(pattern))
|
179
193
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
194
|
+
code.sub(regexp) do |match|
|
195
|
+
indentation = Regexp.last_match(1)
|
196
|
+
replacement = ''
|
197
|
+
Array(comments).each do |comment|
|
198
|
+
comment = comment.to_s.chomp
|
199
|
+
replacement << "#{indentation}# #{comment}\n"
|
200
|
+
end
|
201
|
+
replacement << match
|
186
202
|
end
|
187
|
-
replacement << match
|
188
203
|
end
|
189
204
|
end
|
190
205
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
206
|
+
include CodeExampleHelper
|
207
|
+
|
208
|
+
module SupportedRubyListHelper
|
209
|
+
def supported_ruby_names
|
210
|
+
supported_ruby_ids.map { |id| ruby_name_from(id) }
|
211
|
+
end
|
212
|
+
|
213
|
+
def ruby_name_from(id)
|
214
|
+
implementation, version = id.split('-', 2)
|
215
|
+
|
216
|
+
if implementation == 'jruby'
|
217
|
+
implementation = 'JRuby'
|
218
|
+
elsif version.nil?
|
219
|
+
version = implementation
|
220
|
+
implementation = 'MRI'
|
221
|
+
end
|
222
|
+
|
223
|
+
"#{implementation} #{version}"
|
224
|
+
end
|
225
|
+
|
226
|
+
def supported_ruby_ids
|
227
|
+
travis_config['rvm'] - unsupported_ruby_ids
|
228
|
+
end
|
229
|
+
|
230
|
+
def unsupported_ruby_ids
|
231
|
+
return [] unless travis_config['matrix']
|
232
|
+
travis_config['matrix']['allow_failures'].map { |build| build['rvm'] }.compact
|
233
|
+
end
|
234
|
+
|
235
|
+
def travis_config
|
236
|
+
@travis_config ||= begin
|
237
|
+
require 'yaml'
|
238
|
+
YAML.parse_file('.travis.yml').to_ruby
|
239
|
+
end
|
195
240
|
end
|
196
241
|
end
|
242
|
+
|
243
|
+
include SupportedRubyListHelper
|
197
244
|
end
|
data/transpec.gemspec
CHANGED
@@ -21,9 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ['lib']
|
23
23
|
|
24
|
-
spec.required_ruby_version = '>=
|
24
|
+
spec.required_ruby_version = '>= 2.0.0'
|
25
25
|
|
26
|
-
spec.add_runtime_dependency 'parser', '>= 2.
|
26
|
+
spec.add_runtime_dependency 'parser', '>= 2.5.0.0'
|
27
27
|
spec.add_runtime_dependency 'astrolabe', '~> 1.2'
|
28
28
|
spec.add_runtime_dependency 'bundler', '~> 1.3'
|
29
29
|
spec.add_runtime_dependency 'rainbow', '>= 1.99.1', '< 3.0'
|
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: 3.
|
4
|
+
version: 3.4.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:
|
11
|
+
date: 2018-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.5.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.5.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: astrolabe
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,7 +221,6 @@ files:
|
|
221
221
|
- tasks/lib/test.rb
|
222
222
|
- tasks/readme.rake
|
223
223
|
- tasks/spec.rake
|
224
|
-
- tasks/test.rake
|
225
224
|
- transpec.gemspec
|
226
225
|
homepage: http://yujinakayama.me/transpec/
|
227
226
|
licenses:
|
@@ -235,7 +234,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
235
234
|
requirements:
|
236
235
|
- - ">="
|
237
236
|
- !ruby/object:Gem::Version
|
238
|
-
version:
|
237
|
+
version: 2.0.0
|
239
238
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
240
239
|
requirements:
|
241
240
|
- - ">="
|
@@ -243,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
242
|
version: '0'
|
244
243
|
requirements: []
|
245
244
|
rubyforge_project:
|
246
|
-
rubygems_version: 2.
|
245
|
+
rubygems_version: 2.7.7
|
247
246
|
signing_key:
|
248
247
|
specification_version: 4
|
249
248
|
summary: The RSpec syntax converter
|
data/tasks/test.rake
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require_relative 'lib/test'
|
4
|
-
|
5
|
-
namespace :test do
|
6
|
-
# On Travis CI, reuse system gems to speed up build.
|
7
|
-
bundler_args = if ENV['TRAVIS']
|
8
|
-
[]
|
9
|
-
else
|
10
|
-
%w(--path vendor/bundle)
|
11
|
-
end
|
12
|
-
|
13
|
-
# rubocop:disable LineLength
|
14
|
-
tests = [
|
15
|
-
Test.new('https://github.com/yujinakayama/twitter.git', 'transpec-test-rspec-2-99', bundler_args),
|
16
|
-
Test.new('https://github.com/yujinakayama/mail.git', 'transpec-test-rspec-2-99', bundler_args),
|
17
|
-
# Test.new('https://github.com/yujinakayama/guard.git', 'transpec-test-rspec-2-99', bundler_args + %w(--without development))
|
18
|
-
]
|
19
|
-
# rubocop:enable LineLength
|
20
|
-
|
21
|
-
desc 'Test transpec on all projects'
|
22
|
-
task all: tests.map(&:name)
|
23
|
-
|
24
|
-
tests.each do |test|
|
25
|
-
desc "Test transpec on #{test.name} project"
|
26
|
-
task test.name do
|
27
|
-
test.run
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|