synvert-core 1.30.2 → 1.30.3

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: 5fce0db1974beb18ed0cdfbaae3e68e11c50c3f7ba4bd0dc5904dd7b2035975b
4
- data.tar.gz: 7de77483010cb937b6ae1020579d0d8c21889f9c4076a47c8d3a379e23fd76c1
3
+ metadata.gz: 2c2557aab985fb34048581b6b768d40c012a8f4e2403987a43350c837890d991
4
+ data.tar.gz: 2f9d14d1c0632282d9d5d259dc21a25db4f245b4aa44302baabfa63e14a4f25a
5
5
  SHA512:
6
- metadata.gz: 175fc9b3ffef5f498d68667aa766a62c739940e3f2f525277c2a6c196ca4a33c025ace8b4d7dbb13ef41596e873f6fa477e46b35ddaa319fb0484debac0e5730
7
- data.tar.gz: 3c43b3b9d6319998e5c9dd628c68890481c57974d68937a52586762d606772099f04f702b337a0cd1192bae733cd122d7d09742318893b1fa0ce14ed25b6fe4a
6
+ metadata.gz: dbe85c0e46b4eff9be065c257105a4d22f15d1ee14ebacb0a3b6a638c8727862f984358e4204b3551ea567323eab784f35e1274f50c9ab8b2cad3417cbcdc299
7
+ data.tar.gz: 0a8ffa195df715505e6fdd5e7aa2694b9a34aba1ea4ba0e34256fca5763a4d9a722fdb16e2a417a28eb9fa197e3b3e597708103bb2bc9989773dfe2d9f15ca89
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.30.3 (2024-01-13)
4
+
5
+ * Add `Configuration.test_result` option
6
+
3
7
  ## 1.30.2 (2024-01-09)
4
8
 
5
9
  * Add `Configuration.strict` option
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- synvert-core (1.30.2)
4
+ synvert-core (1.30.3)
5
5
  activesupport (< 7.0.0)
6
6
  node_mutation (>= 1.21.6)
7
7
  node_query (>= 1.13.12)
@@ -48,7 +48,7 @@ GEM
48
48
  rb-inotify (~> 0.9, >= 0.9.10)
49
49
  lumberjack (1.2.8)
50
50
  method_source (1.0.0)
51
- minitest (5.20.0)
51
+ minitest (5.21.1)
52
52
  nenv (0.3.0)
53
53
  node_mutation (1.22.2)
54
54
  node_query (1.14.1)
@@ -56,7 +56,7 @@ GEM
56
56
  nenv (~> 0.1)
57
57
  shellany (~> 0.0)
58
58
  parallel (1.24.0)
59
- parser (3.3.0.2)
59
+ parser (3.3.0.3)
60
60
  ast (~> 2.4.1)
61
61
  racc
62
62
  parser_node_ext (1.2.1)
@@ -12,6 +12,7 @@ module Synvert::Core
12
12
  # @!attribute [w] single_quote
13
13
  # @!attribute [w] tab_width
14
14
  # @!attribute [w] strict, if strict is false, it will ignore ruby version and gem version check.
15
+ # @!attribute [w] test_result, default is 'actions', it can be 'actions' or 'new_source'.
15
16
  attr_writer :root_path,
16
17
  :skip_paths,
17
18
  :only_paths,
@@ -19,7 +20,8 @@ module Synvert::Core
19
20
  :number_of_workers,
20
21
  :single_quote,
21
22
  :tab_width,
22
- :strict
23
+ :strict,
24
+ :test_result
23
25
 
24
26
  # Get the path.
25
27
  #
@@ -80,6 +82,15 @@ module Synvert::Core
80
82
  def strict
81
83
  @strict.nil? ? true : @strict
82
84
  end
85
+
86
+ # Returns the value of the test_result flag.
87
+ #
88
+ # If the test_result flag is not set, it returns 'actions' by default.
89
+ #
90
+ # @return [String] the value of the test_result flag
91
+ def test_result
92
+ @test_result || 'actions'
93
+ end
83
94
  end
84
95
  end
85
96
  end
@@ -88,7 +88,7 @@ module Synvert::Core
88
88
  instance_eval(&@block)
89
89
  end
90
90
 
91
- result = @current_mutation.test
91
+ result = Configuration.test_result == 'new_source' ? @current_mutation.process : @current_mutation.test
92
92
  result.file_path = file_path
93
93
  result
94
94
  rescue Parser::SyntaxError => e
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '1.30.2'
5
+ VERSION = '1.30.3'
6
6
  end
7
7
  end
@@ -429,7 +429,7 @@ module Synvert::Core
429
429
  describe '#test' do
430
430
  let(:rewriter) { Rewriter.new('foo', 'bar') }
431
431
 
432
- it 'gets actions if afected' do
432
+ it 'gets actions if affected' do
433
433
  instance =
434
434
  Rewriter::Instance.new rewriter, 'spec/models/post_spec.rb' do
435
435
  with_node type: 'send', receiver: 'FactoryGirl', message: 'create' do
@@ -452,6 +452,37 @@ module Synvert::Core
452
452
  ]
453
453
  end
454
454
 
455
+ context 'Configuration.test_result is new_source' do
456
+ before { Configuration.test_result = 'new_source' }
457
+ after { Configuration.test_result = nil }
458
+
459
+ it 'gets new_source if Configuration.test_result is new_source' do
460
+ instance =
461
+ Rewriter::Instance.new rewriter, 'spec/models/post_spec.rb' do
462
+ with_node type: 'send', receiver: 'FactoryGirl', message: 'create' do
463
+ replace_with 'create {{arguments}}'
464
+ end
465
+ end
466
+ input = <<~EOS
467
+ it 'uses factory_girl' do
468
+ user = FactoryGirl.create :user
469
+ post = FactoryGirl.create :post, user: user
470
+ assert post.valid?
471
+ end
472
+ EOS
473
+ expect(File).to receive(:read).with('./spec/models/post_spec.rb', encoding: 'UTF-8').and_return(input)
474
+ results = instance.test
475
+ expect(results.file_path).to eq 'spec/models/post_spec.rb'
476
+ expect(results.new_source).to eq <<~EOS
477
+ it 'uses factory_girl' do
478
+ user = create :user
479
+ post = create :post, user: user
480
+ assert post.valid?
481
+ end
482
+ EOS
483
+ end
484
+ end
485
+
455
486
  it 'gets nothing if not affected' do
456
487
  instance =
457
488
  Rewriter::Instance.new rewriter, 'spec/spec_helper.rb' do
@@ -591,7 +622,7 @@ module Synvert::Core
591
622
 
592
623
  context 'Configuration.single_quote = false' do
593
624
  before { Configuration.single_quote = false }
594
- after { Configuration.single_quote = true }
625
+ after { Configuration.single_quote = nil }
595
626
 
596
627
  it 'wraps with double quotes' do
597
628
  expect(instance.wrap_with_quotes('foobar')).to eq '"foobar"'
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: 1.30.2
4
+ version: 1.30.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-09 00:00:00.000000000 Z
11
+ date: 2024-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport