transpec 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/CHANGELOG.md +4 -0
- data/Rakefile +60 -0
- data/lib/transpec/syntax/expectizable.rb +1 -1
- data/lib/transpec/util.rb +4 -13
- data/lib/transpec/version.rb +1 -1
- data/lib/transpec.rb +7 -0
- data/spec/spec_spec.rb +2 -2
- data/spec/transpec/syntax/matcher_spec.rb +22 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4de7050825b2892a104decbe5977f02054f4d57
|
4
|
+
data.tar.gz: 26acc442dbdfcbf63b93b94556dc6406a63165b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2efb1b828b2c2e713e4d904cd34369abe134bb8d0cc0cc4381d06785cf77ef31ca7eae2f0f42298421c3603c498d3b85b66a4e72fdc1bb55a4c29cd30b2c2f7d
|
7
|
+
data.tar.gz: 367775428c9155fd721a33621b2cf561ea3c684d16baead448019bcd3f7e9008f2f30a55771dc9ca2f2c45d3e12e665830967945fcce78f5578b1791446018e9
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## Master
|
4
4
|
|
5
|
+
## v0.0.4
|
6
|
+
|
7
|
+
* Fix a bug where necessary parentheses were not added when converting operator matcher to non-operator matcher in some cases (e.g. `== (2 - 1) + (1 + 2)` was converted into `eq(2 - 1) + (1 + 2)` unintentionally)
|
8
|
+
|
5
9
|
## v0.0.3
|
6
10
|
|
7
11
|
* Suppress addition of superfluous parentheses when converting operator matcher that have argument in parentheses to non-operator matcher (e.g. from `== (2 - 1)` to `eq(2 - 1)`)
|
data/Rakefile
CHANGED
@@ -42,4 +42,64 @@ end
|
|
42
42
|
|
43
43
|
Rake::Task[:release].enhance([:abort_unless_latest_readme_is_committed])
|
44
44
|
|
45
|
+
namespace :test do
|
46
|
+
projects = [
|
47
|
+
[:twitter, 'https://github.com/sferik/twitter.git', 'v4.1.0'],
|
48
|
+
[:guard, 'https://github.com/guard/guard.git', 'v1.8.1', '--without development']
|
49
|
+
]
|
50
|
+
|
51
|
+
desc 'Test Transpec on all other projects'
|
52
|
+
task :all => projects.map(&:first)
|
53
|
+
|
54
|
+
projects.each do |name, url, ref, bundler_args|
|
55
|
+
desc "Test Transpec on #{name.to_s.capitalize} project"
|
56
|
+
task name do
|
57
|
+
require 'tmpdir'
|
58
|
+
|
59
|
+
Dir.chdir(Dir.mktmpdir) do
|
60
|
+
test_on_project(name.to_s.capitalize, url, ref, bundler_args)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_on_project(name, url, ref, bundler_args = nil)
|
66
|
+
require 'transpec'
|
67
|
+
|
68
|
+
puts " Testing on #{name} Project ".center(80, '=')
|
69
|
+
|
70
|
+
# Disabling checkout here to suppress "detached HEAD" warning.
|
71
|
+
sh "git clone --no-checkout --depth 1 --branch #{ref} #{url}"
|
72
|
+
|
73
|
+
repo_dir = File.basename(url, '.git')
|
74
|
+
|
75
|
+
Dir.chdir(repo_dir) do
|
76
|
+
sh "git checkout --quiet #{ref}"
|
77
|
+
with_clean_bundler_env do
|
78
|
+
sh "bundle install #{bundler_args}"
|
79
|
+
sh File.join(Transpec.root, 'bin', 'transpec')
|
80
|
+
sh 'rspec'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def with_clean_bundler_env
|
86
|
+
if defined?(Bundler)
|
87
|
+
Bundler.with_clean_env do
|
88
|
+
# Bundler.with_clean_env cleans environment variables
|
89
|
+
# which are set after bundler is loaded.
|
90
|
+
prepare_env
|
91
|
+
yield
|
92
|
+
end
|
93
|
+
else
|
94
|
+
prepare_env
|
95
|
+
yield
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def prepare_env
|
100
|
+
# Disable Coveralls in other projects.
|
101
|
+
ENV['CI'] = ENV['JENKINS_URL'] = ENV['COVERALLS_RUN_LOCALLY'] = nil
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
45
105
|
task default: [:spec, :style, :readme]
|
data/lib/transpec/util.rb
CHANGED
@@ -41,19 +41,10 @@ module Transpec
|
|
41
41
|
node.loc.begin.source.start_with?('<<')
|
42
42
|
end
|
43
43
|
|
44
|
-
def in_parentheses?(
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
when Parser::Source::Range
|
49
|
-
subject.source
|
50
|
-
when Parser::AST::Node
|
51
|
-
subject.loc.expression.source
|
52
|
-
else
|
53
|
-
fail ArgumentError
|
54
|
-
end
|
55
|
-
|
56
|
-
source[0] == '('
|
44
|
+
def in_parentheses?(node)
|
45
|
+
return false unless node.type == :begin
|
46
|
+
source = node.loc.expression.source
|
47
|
+
source[0] == '(' && source[-1] == ')'
|
57
48
|
end
|
58
49
|
|
59
50
|
def indentation_of_line(node)
|
data/lib/transpec/version.rb
CHANGED
data/lib/transpec.rb
ADDED
data/spec/spec_spec.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
+
require 'transpec'
|
4
5
|
require 'tmpdir'
|
5
6
|
require 'English'
|
6
7
|
|
@@ -8,8 +9,7 @@ describe 'Transpec project spec', :do_not_run_in_converted_spec do
|
|
8
9
|
copied_project_root = Dir.mktmpdir
|
9
10
|
|
10
11
|
before(:all) do
|
11
|
-
|
12
|
-
Dir.chdir(project_root) do
|
12
|
+
Dir.chdir(Transpec.root) do
|
13
13
|
FileUtils.cp_r(Dir['*'], copied_project_root)
|
14
14
|
end
|
15
15
|
end
|
@@ -155,6 +155,28 @@ module Transpec
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
|
+
context 'when it is `== (2 - 1) + (1 + 2)` form' do
|
159
|
+
let(:source) do
|
160
|
+
<<-END
|
161
|
+
it 'is 1' do
|
162
|
+
subject.should == (2 - 1) + (1 + 2)
|
163
|
+
end
|
164
|
+
END
|
165
|
+
end
|
166
|
+
|
167
|
+
let(:expected_source) do
|
168
|
+
<<-END
|
169
|
+
it 'is 1' do
|
170
|
+
subject.should eq((2 - 1) + (1 + 2))
|
171
|
+
end
|
172
|
+
END
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'converts into `eq((2 - 1) + (1 + 2))` form' do
|
176
|
+
rewritten_source.should == expected_source
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
158
180
|
context "when it is `== { 'key' => 'value' }` form" do
|
159
181
|
let(:source) do
|
160
182
|
<<-END
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transpec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuji Nakayama
|
@@ -170,6 +170,7 @@ files:
|
|
170
170
|
- README.md.erb
|
171
171
|
- Rakefile
|
172
172
|
- bin/transpec
|
173
|
+
- lib/transpec.rb
|
173
174
|
- lib/transpec/ast/scanner.rb
|
174
175
|
- lib/transpec/ast/scope_stack.rb
|
175
176
|
- lib/transpec/cli.rb
|