synvert-core 0.16.1 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 327989a145ffc5562768e51cf54f6a86ad2bed0b329c7398eb9499a3fa0f4b07
4
- data.tar.gz: d7cb9ca59c8a821329b7063e515a329ab451a83ce80439028af458d9cf745804
3
+ metadata.gz: b73d8898436945c3266c9d0e4eec002491c3b031e1d571f94b3a59443142a9dd
4
+ data.tar.gz: c8afb1ce36ef5d3e826ebbc7ca10103175661e14f8ea1af1ae5a1a83b8714dbf
5
5
  SHA512:
6
- metadata.gz: 7e3afcda5002e5d275faba969dc193e0d8f88781e647ab7fecb44bbbe3b0de383aa74bfad2341b406e148005c4ec7b44fbe941ab884f2a1968d4c81ec1cb9080
7
- data.tar.gz: 2b504f8c0a822ae0874e154d45f811b9301bda4c7399bf4c54c365d30bf719367d17a04f0bd41fd77c618c0045901bf70e825301b3811ba023fe0f20bf1c17d5
6
+ metadata.gz: b7198c44b3696f0c0f640fe378ff3b9923799517998d6be38177096a552b33885bf5df6113d1aa1a0b68432bff79d0322587648d221bd6fbaebcf75ab8b2d32d
7
+ data.tar.gz: 39b8bf09735971e108b112b96b3377df988b82e891c76d5050fef978aec81bf340ff096463ac9416848fd9b8e412b95537377d0647d11a6028d5ab909cac4fa4
@@ -1,6 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
- * Abstract `find_matching_nodes`
3
+ ## 0.17.0 (2021-01-29)
4
+
5
+ * Ignore `gem_spec` check if `Gemfile.lock` does not eixst
4
6
 
5
7
  ## 0.16.0 (2021-01-17)
6
8
 
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "synvert/core/version"
4
-
5
- # coding: utf-8
6
3
  require "synvert/core/version"
7
4
  require 'bundler'
8
5
  require 'parser'
@@ -27,15 +27,14 @@ module Synvert::Core
27
27
  # @raise [Synvert::Core::GemfileLockNotFound] raise if Gemfile.lock does not exist.
28
28
  def match?
29
29
  gemfile_lock_path = File.join(Configuration.instance.get(:path), 'Gemfile.lock')
30
- if File.exists? gemfile_lock_path
31
- parser = Bundler::LockfileParser.new(File.read(gemfile_lock_path))
32
- if spec = parser.specs.find { |spec| spec.name == @name }
33
- Gem::Version.new(spec.version).send(OPERATORS[@operator], @version)
34
- else
35
- false
36
- end
30
+ # if Gemfile.lock does not exist, just ignore this check
31
+ return true unless File.exist?(gemfile_lock_path)
32
+
33
+ parser = Bundler::LockfileParser.new(File.read(gemfile_lock_path))
34
+ if spec = parser.specs.find { |spec| spec.name == @name }
35
+ Gem::Version.new(spec.version).send(OPERATORS[@operator], @version)
37
36
  else
38
- raise GemfileLockNotFound.new 'Gemfile.lock does not exist'
37
+ false
39
38
  end
40
39
  end
41
40
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = "0.16.1"
5
+ VERSION = "0.17.0"
6
6
  end
7
7
  end
@@ -30,10 +30,10 @@ module Synvert::Core
30
30
  source = " its(:size) { should == 1 }"
31
31
  send_node = Parser::CurrentRuby.parse(source)
32
32
  instance = double(current_node: send_node)
33
- Rewriter::ReplaceWithAction.new(instance, """describe '#size' do
33
+ Rewriter::ReplaceWithAction.new(instance, "describe '#size' do
34
34
  subject { super().size }
35
35
  it { {{body}} }
36
- end""", autoindent: false)
36
+ end", autoindent: false)
37
37
  }
38
38
 
39
39
  it 'gets begin_pos' do
@@ -45,10 +45,10 @@ end""", autoindent: false)
45
45
  end
46
46
 
47
47
  it 'gets rewritten_code' do
48
- expect(subject.rewritten_code).to eq """describe '#size' do
48
+ expect(subject.rewritten_code).to eq "describe '#size' do
49
49
  subject { super().size }
50
50
  it { should == 1 }
51
- end"""
51
+ end"
52
52
  end
53
53
  end
54
54
  end
@@ -5,12 +5,12 @@ require 'spec_helper'
5
5
  module Synvert::Core
6
6
  describe Rewriter::IfExistCondition do
7
7
  let(:source) {
8
- """
8
+ "
9
9
  RSpec.configure do |config|
10
10
  config.include EmailSpec::Helpers
11
11
  config.include EmailSpec::Methods
12
12
  end
13
- """
13
+ "
14
14
  }
15
15
  let(:node) { Parser::CurrentRuby.parse(source) }
16
16
  let(:instance) { double(:current_node => node) }
@@ -5,23 +5,23 @@ require 'spec_helper'
5
5
  module Synvert::Core
6
6
  describe Rewriter::IfOnlyExistCondition do
7
7
  let(:source) {
8
- """
8
+ "
9
9
  RSpec.configure do |config|
10
10
  config.include EmailSpec::Helpers
11
11
  config.include EmailSpec::Methods
12
12
  end
13
- """
13
+ "
14
14
  }
15
15
  let(:node) { Parser::CurrentRuby.parse(source) }
16
16
  let(:instance) { double(:current_node => node) }
17
17
 
18
18
  describe '#process' do
19
19
  it 'gets matching nodes' do
20
- source = """
20
+ source = "
21
21
  RSpec.configure do |config|
22
22
  config.include EmailSpec::Helpers
23
23
  end
24
- """
24
+ "
25
25
  node = Parser::CurrentRuby.parse(source)
26
26
  instance = double(:current_node => node)
27
27
  run = false
@@ -5,12 +5,12 @@ require 'spec_helper'
5
5
  module Synvert::Core
6
6
  describe Rewriter::UnlessExistCondition do
7
7
  let(:source) {
8
- """
8
+ "
9
9
  RSpec.configure do |config|
10
10
  config.include EmailSpec::Helpers
11
11
  config.include EmailSpec::Methods
12
12
  end
13
- """
13
+ "
14
14
  }
15
15
  let(:node) { Parser::CurrentRuby.parse(source) }
16
16
  let(:instance) { double(:current_node => node) }
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  module Synvert::Core
6
6
  describe Rewriter::GemSpec do
7
- let(:gemfile_lock_content) { """
7
+ let(:gemfile_lock_content) { "
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
@@ -14,41 +14,40 @@ GEM
14
14
  slop (~> 3.4, >= 3.4.5)
15
15
  rake (10.1.1)
16
16
  slop (3.4.7)
17
- """
18
- }
17
+ "}
19
18
 
20
19
  it 'returns true if version in Gemfile.lock is greater than definition' do
21
- expect(File).to receive(:exists?).with('./Gemfile.lock').and_return(true)
20
+ expect(File).to receive(:exist?).with('./Gemfile.lock').and_return(true)
22
21
  expect(File).to receive(:read).with('./Gemfile.lock').and_return(gemfile_lock_content)
23
22
  gem_spec = Rewriter::GemSpec.new('ast', {gte: '1.0.0'})
24
23
  expect(gem_spec).to be_match
25
24
  end
26
25
 
27
26
  it 'returns true if version in Gemfile.lock is equal to definition' do
28
- expect(File).to receive(:exists?).with('./Gemfile.lock').and_return(true)
27
+ expect(File).to receive(:exist?).with('./Gemfile.lock').and_return(true)
29
28
  expect(File).to receive(:read).with('./Gemfile.lock').and_return(gemfile_lock_content)
30
29
  gem_spec = Rewriter::GemSpec.new('ast', '1.1.0')
31
30
  expect(gem_spec).to be_match
32
31
  end
33
32
 
34
33
  it 'returns false if version in Gemfile.lock is less than definition' do
35
- expect(File).to receive(:exists?).with('./Gemfile.lock').and_return(true)
34
+ expect(File).to receive(:exist?).with('./Gemfile.lock').and_return(true)
36
35
  expect(File).to receive(:read).with('./Gemfile.lock').and_return(gemfile_lock_content)
37
36
  gem_spec = Rewriter::GemSpec.new('ast', {gt: '1.2.0'})
38
37
  expect(gem_spec).not_to be_match
39
38
  end
40
39
 
41
40
  it 'returns false if gem does not exist in Gemfile.lock' do
42
- expect(File).to receive(:exists?).with('./Gemfile.lock').and_return(true)
41
+ expect(File).to receive(:exist?).with('./Gemfile.lock').and_return(true)
43
42
  expect(File).to receive(:read).with('./Gemfile.lock').and_return(gemfile_lock_content)
44
43
  gem_spec = Rewriter::GemSpec.new('synvert', '1.0.0')
45
44
  expect(gem_spec).not_to be_match
46
45
  end
47
46
 
48
47
  it 'raise Synvert::Core::GemfileLockNotFound if Gemfile.lock does not exist' do
49
- expect(File).to receive(:exists?).with('./Gemfile.lock').and_return(false)
48
+ expect(File).to receive(:exist?).with('./Gemfile.lock').and_return(false)
50
49
  gem_spec = Rewriter::GemSpec.new('ast', '1.1.0')
51
- expect { gem_spec.match? }.to raise_error(Synvert::Core::GemfileLockNotFound)
50
+ expect(gem_spec).to be_match
52
51
  end
53
52
  end
54
53
  end
@@ -114,20 +114,20 @@ module Synvert::Core
114
114
  replace_with 'create {{arguments}}'
115
115
  end
116
116
  end
117
- input = """
117
+ input = "
118
118
  it 'uses factory_girl' do
119
119
  user = FactoryGirl.create :user
120
120
  post = FactoryGirl.create :post, user: user
121
121
  assert post.valid?
122
122
  end
123
- """
124
- output = """
123
+ "
124
+ output = "
125
125
  it 'uses factory_girl' do
126
126
  user = create :user
127
127
  post = create :post, user: user
128
128
  assert post.valid?
129
129
  end
130
- """
130
+ "
131
131
  expect(Dir).to receive(:glob).with('./spec/**/*_spec.rb').and_return(['spec/models/post_spec.rb'])
132
132
  expect(File).to receive(:read).with('spec/models/post_spec.rb').and_return(input)
133
133
  expect(File).to receive(:write).with('spec/models/post_spec.rb', output)
@@ -142,16 +142,16 @@ end
142
142
  end
143
143
  end
144
144
  end
145
- input = """
145
+ input = "
146
146
  RSpec.configure do |config|
147
147
  config.include FactoryGirl::Syntax::Methods
148
148
  end
149
- """
150
- output = """
149
+ "
150
+ output = "
151
151
  RSpec.configure do |config|
152
152
  config.include FactoryGirl::Syntax::Methods
153
153
  end
154
- """
154
+ "
155
155
  expect(Dir).to receive(:glob).with('./spec/spec_helper.rb').and_return(['spec/spec_helper.rb'])
156
156
  expect(File).to receive(:read).with('spec/spec_helper.rb').and_return(input)
157
157
  expect(File).not_to receive(:write).with('spec/spec_helper.rb', output)
@@ -166,16 +166,16 @@ end
166
166
  end
167
167
  end
168
168
  end
169
- input = """
169
+ input = "
170
170
  RSpec.configure do |config|
171
171
  config.include FactoryGirl::Syntax::Methods
172
172
  end
173
- """
174
- output = """
173
+ "
174
+ output = "
175
175
  RSpec.configure do |config|
176
176
  config.include FactoryGirl::Syntax::Methods
177
177
  end
178
- """
178
+ "
179
179
  expect(Dir).to receive(:glob).with('./spec/spec_helper.rb').and_return(['spec/spec_helper.rb']).twice
180
180
  expect(File).to receive(:read).with('spec/spec_helper.rb').and_return(input).once
181
181
  expect(File).not_to receive(:write).with('spec/spec_helper.rb', output)
@@ -189,20 +189,20 @@ end
189
189
  replace_with 'create {{arguments}}'
190
190
  end
191
191
  end
192
- input = """
192
+ input = "
193
193
  it 'uses factory_girl' do
194
194
  user = FactoryGirl.create :user
195
195
  post = FactoryGirl.create :post, user: user
196
196
  assert post.valid?
197
197
  end
198
- """
199
- output = """
198
+ "
199
+ output = "
200
200
  it 'uses factory_girl' do
201
201
  user = create :user
202
202
  post = create :post, user: user
203
203
  assert post.valid?
204
204
  end
205
- """
205
+ "
206
206
  expect(Dir).to receive(:glob).with('./spec/**/*_spec.rb').and_return(['spec/models/post_spec.rb']).twice
207
207
  expect(File).to receive(:read).with('spec/models/post_spec.rb').and_return(input)
208
208
  expect(File).to receive(:write).with('spec/models/post_spec.rb', output)
@@ -8,13 +8,13 @@ module Synvert::Core
8
8
  rewriter = Rewriter.new('foo', 'bar')
9
9
  Rewriter::Instance.new(rewriter, 'file pattern')
10
10
  }
11
- let(:source) {"""
11
+ let(:source) {"
12
12
  describe Post do
13
13
  it 'gets post' do
14
14
  FactoryGirl.create :post
15
15
  end
16
16
  end
17
- """
17
+ "
18
18
  }
19
19
  let(:node) { Parser::CurrentRuby.parse(source) }
20
20
  before do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synvert-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.1
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-28 00:00:00.000000000 Z
11
+ date: 2021-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser