synvert-core 0.15.1 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -2
  3. data/Gemfile +2 -0
  4. data/Guardfile +2 -0
  5. data/Rakefile +2 -0
  6. data/lib/synvert/core.rb +2 -3
  7. data/lib/synvert/core/configuration.rb +2 -1
  8. data/lib/synvert/core/engine.rb +1 -1
  9. data/lib/synvert/core/engine/erb.rb +31 -23
  10. data/lib/synvert/core/exceptions.rb +5 -3
  11. data/lib/synvert/core/node_ext.rb +107 -101
  12. data/lib/synvert/core/rewriter.rb +20 -14
  13. data/lib/synvert/core/rewriter/action.rb +5 -7
  14. data/lib/synvert/core/rewriter/action/append_action.rb +8 -6
  15. data/lib/synvert/core/rewriter/action/insert_action.rb +18 -19
  16. data/lib/synvert/core/rewriter/action/insert_after_action.rb +2 -2
  17. data/lib/synvert/core/rewriter/action/remove_action.rb +2 -2
  18. data/lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb +5 -4
  19. data/lib/synvert/core/rewriter/action/replace_with_action.rb +7 -5
  20. data/lib/synvert/core/rewriter/condition.rb +1 -1
  21. data/lib/synvert/core/rewriter/condition/if_exist_condition.rb +2 -2
  22. data/lib/synvert/core/rewriter/condition/if_only_exist_condition.rb +2 -3
  23. data/lib/synvert/core/rewriter/condition/unless_exist_condition.rb +2 -2
  24. data/lib/synvert/core/rewriter/gem_spec.rb +10 -10
  25. data/lib/synvert/core/rewriter/helper.rb +4 -6
  26. data/lib/synvert/core/rewriter/instance.rb +36 -22
  27. data/lib/synvert/core/rewriter/ruby_version.rb +1 -1
  28. data/lib/synvert/core/rewriter/scope.rb +1 -1
  29. data/lib/synvert/core/rewriter/scope/goto_scope.rb +2 -1
  30. data/lib/synvert/core/rewriter/scope/within_scope.rb +23 -7
  31. data/lib/synvert/core/rewriter/warning.rb +1 -1
  32. data/lib/synvert/core/version.rb +2 -2
  33. data/spec/spec_helper.rb +3 -1
  34. data/spec/support/parser_helper.rb +2 -0
  35. data/spec/synvert/core/configuration_spec.rb +3 -1
  36. data/spec/synvert/core/engine/erb_spec.rb +32 -30
  37. data/spec/synvert/core/node_ext_spec.rb +57 -54
  38. data/spec/synvert/core/rewriter/action/append_action_spec.rb +2 -0
  39. data/spec/synvert/core/rewriter/action/insert_action_spec.rb +10 -8
  40. data/spec/synvert/core/rewriter/action/insert_after_action_spec.rb +5 -3
  41. data/spec/synvert/core/rewriter/action/remove_action_spec.rb +3 -1
  42. data/spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb +2 -0
  43. data/spec/synvert/core/rewriter/action/replace_with_action_spec.rb +17 -11
  44. data/spec/synvert/core/rewriter/action_spec.rb +2 -0
  45. data/spec/synvert/core/rewriter/condition/if_exist_condition_spec.rb +19 -9
  46. data/spec/synvert/core/rewriter/condition/if_only_exist_condition_spec.rb +23 -12
  47. data/spec/synvert/core/rewriter/condition/unless_exist_condition_spec.rb +19 -9
  48. data/spec/synvert/core/rewriter/condition_spec.rb +2 -0
  49. data/spec/synvert/core/rewriter/gem_spec_spec.rb +13 -10
  50. data/spec/synvert/core/rewriter/helper_spec.rb +36 -31
  51. data/spec/synvert/core/rewriter/instance_spec.rb +118 -66
  52. data/spec/synvert/core/rewriter/scope/goto_scope_spec.rb +10 -6
  53. data/spec/synvert/core/rewriter/scope/within_scope.rb +18 -9
  54. data/spec/synvert/core/rewriter/scope_spec.rb +2 -0
  55. data/spec/synvert/core/rewriter/warning_spec.rb +2 -0
  56. data/spec/synvert/core/rewriter_spec.rb +106 -73
  57. data/synvert-core.gemspec +2 -2
  58. metadata +12 -12
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Synvert::Core
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Synvert::Core
@@ -11,11 +13,11 @@ module Synvert::Core
11
13
  }
12
14
 
13
15
  it 'gets begin_pos' do
14
- expect(subject.begin_pos).to eq "Synvert::Application.configure do".length
16
+ expect(subject.begin_pos).to eq 'Synvert::Application.configure do'.length
15
17
  end
16
18
 
17
19
  it 'gets end_pos' do
18
- expect(subject.end_pos).to eq "Synvert::Application.configure do".length
20
+ expect(subject.end_pos).to eq 'Synvert::Application.configure do'.length
19
21
  end
20
22
 
21
23
  it 'gets rewritten_code' do
@@ -32,11 +34,11 @@ module Synvert::Core
32
34
  }
33
35
 
34
36
  it 'gets begin_pos' do
35
- expect(subject.begin_pos).to eq "RSpec.configure do |config|".length
37
+ expect(subject.begin_pos).to eq 'RSpec.configure do |config|'.length
36
38
  end
37
39
 
38
40
  it 'gets end_pos' do
39
- expect(subject.end_pos).to eq "RSpec.configure do |config|".length
41
+ expect(subject.end_pos).to eq 'RSpec.configure do |config|'.length
40
42
  end
41
43
 
42
44
  it 'gets rewritten_code' do
@@ -53,11 +55,11 @@ module Synvert::Core
53
55
  }
54
56
 
55
57
  it 'gets begin_pos' do
56
- expect(subject.begin_pos).to eq "class User".length
58
+ expect(subject.begin_pos).to eq 'class User'.length
57
59
  end
58
60
 
59
61
  it 'gets end_pos' do
60
- expect(subject.end_pos).to eq "class User".length
62
+ expect(subject.end_pos).to eq 'class User'.length
61
63
  end
62
64
 
63
65
  it 'gets rewritten_code' do
@@ -74,11 +76,11 @@ module Synvert::Core
74
76
  }
75
77
 
76
78
  it 'gets begin_pos' do
77
- expect(subject.begin_pos).to eq "class User < ActionRecord::Base".length
79
+ expect(subject.begin_pos).to eq 'class User < ActionRecord::Base'.length
78
80
  end
79
81
 
80
82
  it 'gets end_pos' do
81
- expect(subject.end_pos).to eq "class User < ActionRecord::Base".length
83
+ expect(subject.end_pos).to eq 'class User < ActionRecord::Base'.length
82
84
  end
83
85
 
84
86
  it 'gets rewritten_code' do
@@ -1,20 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Synvert::Core
4
6
  describe Rewriter::InsertAfterAction do
5
7
  subject {
6
- source = " include Foo"
8
+ source = ' include Foo'
7
9
  node = Parser::CurrentRuby.parse(source)
8
10
  instance = double(current_node: node)
9
11
  Rewriter::InsertAfterAction.new(instance, 'include Bar')
10
12
  }
11
13
 
12
14
  it 'gets begin_pos' do
13
- expect(subject.begin_pos).to eq " include Foo".length
15
+ expect(subject.begin_pos).to eq ' include Foo'.length
14
16
  end
15
17
 
16
18
  it 'gets end_pos' do
17
- expect(subject.end_pos).to eq " include Foo".length
19
+ expect(subject.end_pos).to eq ' include Foo'.length
18
20
  end
19
21
 
20
22
  it 'gets rewritten_code' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Synvert::Core
@@ -18,7 +20,7 @@ module Synvert::Core
18
20
  end
19
21
 
20
22
  it 'gets rewritten_code' do
21
- expect(subject.rewritten_code).to eq ""
23
+ expect(subject.rewritten_code).to eq ''
22
24
  end
23
25
  end
24
26
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Synvert::Core
@@ -1,21 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Synvert::Core
4
6
  describe Rewriter::ReplaceWithAction do
5
- context "replace with single line" do
7
+ context 'replace with single line' do
6
8
  subject {
7
- source = "post = FactoryGirl.create_list :post, 2"
9
+ source = 'post = FactoryGirl.create_list :post, 2'
8
10
  send_node = Parser::CurrentRuby.parse(source).children[1]
9
11
  instance = double(current_node: send_node)
10
12
  Rewriter::ReplaceWithAction.new(instance, 'create_list {{arguments}}')
11
13
  }
12
14
 
13
15
  it 'gets begin_pos' do
14
- expect(subject.begin_pos).to eq "post = ".length
16
+ expect(subject.begin_pos).to eq 'post = '.length
15
17
  end
16
18
 
17
19
  it 'gets end_pos' do
18
- expect(subject.end_pos).to eq "post = FactoryGirl.create_list :post, 2".length
20
+ expect(subject.end_pos).to eq 'post = FactoryGirl.create_list :post, 2'.length
19
21
  end
20
22
 
21
23
  it 'gets rewritten_code' do
@@ -23,15 +25,19 @@ module Synvert::Core
23
25
  end
24
26
  end
25
27
 
26
- context "#replace with multiple line" do
28
+ context '#replace with multiple line' do
27
29
  subject {
28
- source = " its(:size) { should == 1 }"
30
+ source = ' its(:size) { should == 1 }'
29
31
  send_node = Parser::CurrentRuby.parse(source)
30
32
  instance = double(current_node: send_node)
31
- Rewriter::ReplaceWithAction.new(instance, """describe '#size' do
33
+ Rewriter::ReplaceWithAction.new(
34
+ instance,
35
+ "describe '#size' do
32
36
  subject { super().size }
33
37
  it { {{body}} }
34
- end""", autoindent: false)
38
+ end",
39
+ autoindent: false
40
+ )
35
41
  }
36
42
 
37
43
  it 'gets begin_pos' do
@@ -39,14 +45,14 @@ end""", autoindent: false)
39
45
  end
40
46
 
41
47
  it 'gets end_pos' do
42
- expect(subject.end_pos).to eq " its(:size) { should == 1 }".length
48
+ expect(subject.end_pos).to eq ' its(:size) { should == 1 }'.length
43
49
  end
44
50
 
45
51
  it 'gets rewritten_code' do
46
- expect(subject.rewritten_code).to eq """describe '#size' do
52
+ expect(subject.rewritten_code).to eq "describe '#size' do
47
53
  subject { super().size }
48
54
  it { should == 1 }
49
- end"""
55
+ end"
50
56
  end
51
57
  end
52
58
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Synvert::Core
@@ -1,33 +1,43 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Synvert::Core
4
6
  describe Rewriter::IfExistCondition do
5
7
  let(:source) {
6
- """
8
+ '
7
9
  RSpec.configure do |config|
8
10
  config.include EmailSpec::Helpers
9
11
  config.include EmailSpec::Methods
10
12
  end
11
- """
13
+ '
12
14
  }
13
15
  let(:node) { Parser::CurrentRuby.parse(source) }
14
- let(:instance) { double(:current_node => node) }
16
+ let(:instance) { double(current_node: node) }
15
17
 
16
18
  describe '#process' do
17
19
  it 'call block if match anything' do
18
20
  run = false
19
- condition = Rewriter::IfExistCondition.new instance, type: 'send', message: 'include', arguments: ['EmailSpec::Helpers'] do
20
- run = true
21
- end
21
+ condition =
22
+ Rewriter::IfExistCondition.new instance,
23
+ type: 'send',
24
+ message: 'include',
25
+ arguments: ['EmailSpec::Helpers'] do
26
+ run = true
27
+ end
22
28
  condition.process
23
29
  expect(run).to be_truthy
24
30
  end
25
31
 
26
32
  it 'not call block if not match anything' do
27
33
  run = false
28
- condition = Rewriter::IfExistCondition.new instance, type: 'send', message: 'include', arguments: ['FactoryGirl::SyntaxMethods'] do
29
- run = true
30
- end
34
+ condition =
35
+ Rewriter::IfExistCondition.new instance,
36
+ type: 'send',
37
+ message: 'include',
38
+ arguments: ['FactoryGirl::SyntaxMethods'] do
39
+ run = true
40
+ end
31
41
  condition.process
32
42
  expect(run).to be_falsey
33
43
  end
@@ -1,40 +1,51 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Synvert::Core
4
6
  describe Rewriter::IfOnlyExistCondition do
5
7
  let(:source) {
6
- """
8
+ '
7
9
  RSpec.configure do |config|
8
10
  config.include EmailSpec::Helpers
9
11
  config.include EmailSpec::Methods
10
12
  end
11
- """
13
+ '
12
14
  }
13
15
  let(:node) { Parser::CurrentRuby.parse(source) }
14
- let(:instance) { double(:current_node => node) }
16
+ let(:instance) { double(current_node: node) }
15
17
 
16
18
  describe '#process' do
17
19
  it 'gets matching nodes' do
18
- source = """
20
+ source =
21
+ '
19
22
  RSpec.configure do |config|
20
23
  config.include EmailSpec::Helpers
21
24
  end
22
- """
25
+ '
23
26
  node = Parser::CurrentRuby.parse(source)
24
- instance = double(:current_node => node)
27
+ instance = double(current_node: node)
25
28
  run = false
26
- condition = Rewriter::IfOnlyExistCondition.new instance, type: 'send', message: 'include', arguments: ['EmailSpec::Helpers'] do
27
- run = true
28
- end
29
+ condition =
30
+ Rewriter::IfOnlyExistCondition.new instance,
31
+ type: 'send',
32
+ message: 'include',
33
+ arguments: ['EmailSpec::Helpers'] do
34
+ run = true
35
+ end
29
36
  condition.process
30
37
  expect(run).to be_truthy
31
38
  end
32
39
 
33
40
  it 'not call block if does not match' do
34
41
  run = false
35
- condition = Rewriter::IfOnlyExistCondition.new instance, type: 'send', message: 'include', arguments: ['EmailSpec::Helpers'] do
36
- run = true
37
- end
42
+ condition =
43
+ Rewriter::IfOnlyExistCondition.new instance,
44
+ type: 'send',
45
+ message: 'include',
46
+ arguments: ['EmailSpec::Helpers'] do
47
+ run = true
48
+ end
38
49
  condition.process
39
50
  expect(run).to be_falsey
40
51
  end
@@ -1,33 +1,43 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Synvert::Core
4
6
  describe Rewriter::UnlessExistCondition do
5
7
  let(:source) {
6
- """
8
+ '
7
9
  RSpec.configure do |config|
8
10
  config.include EmailSpec::Helpers
9
11
  config.include EmailSpec::Methods
10
12
  end
11
- """
13
+ '
12
14
  }
13
15
  let(:node) { Parser::CurrentRuby.parse(source) }
14
- let(:instance) { double(:current_node => node) }
16
+ let(:instance) { double(current_node: node) }
15
17
 
16
18
  describe '#process' do
17
19
  it 'call block if match anything' do
18
20
  run = false
19
- condition = Rewriter::UnlessExistCondition.new instance, type: 'send', message: 'include', arguments: ['FactoryGirl::Syntax::Methods'] do
20
- run = true
21
- end
21
+ condition =
22
+ Rewriter::UnlessExistCondition.new instance,
23
+ type: 'send',
24
+ message: 'include',
25
+ arguments: ['FactoryGirl::Syntax::Methods'] do
26
+ run = true
27
+ end
22
28
  condition.process
23
29
  expect(run).to be_truthy
24
30
  end
25
31
 
26
32
  it 'not call block if not match anything' do
27
33
  run = false
28
- condition = Rewriter::UnlessExistCondition.new instance, type: 'send', message: 'include', arguments: ['EmailSpec::Helpers'] do
29
- run = true
30
- end
34
+ condition =
35
+ Rewriter::UnlessExistCondition.new instance,
36
+ type: 'send',
37
+ message: 'include',
38
+ arguments: ['EmailSpec::Helpers'] do
39
+ run = true
40
+ end
31
41
  condition.process
32
42
  expect(run).to be_falsey
33
43
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Synvert::Core
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Synvert::Core
4
6
  describe Rewriter::GemSpec do
5
- let(:gemfile_lock_content) { """
7
+ let(:gemfile_lock_content) {
8
+ '
6
9
  GEM
7
10
  remote: https://rubygems.org/
8
11
  specs:
@@ -12,41 +15,41 @@ GEM
12
15
  slop (~> 3.4, >= 3.4.5)
13
16
  rake (10.1.1)
14
17
  slop (3.4.7)
15
- """
18
+ '
16
19
  }
17
20
 
18
21
  it 'returns true if version in Gemfile.lock is greater than definition' do
19
- expect(File).to receive(:exists?).with('./Gemfile.lock').and_return(true)
22
+ expect(File).to receive(:exist?).with('./Gemfile.lock').and_return(true)
20
23
  expect(File).to receive(:read).with('./Gemfile.lock').and_return(gemfile_lock_content)
21
- gem_spec = Rewriter::GemSpec.new('ast', {gte: '1.0.0'})
24
+ gem_spec = Rewriter::GemSpec.new('ast', { gte: '1.0.0' })
22
25
  expect(gem_spec).to be_match
23
26
  end
24
27
 
25
28
  it 'returns true if version in Gemfile.lock is equal to definition' do
26
- expect(File).to receive(:exists?).with('./Gemfile.lock').and_return(true)
29
+ expect(File).to receive(:exist?).with('./Gemfile.lock').and_return(true)
27
30
  expect(File).to receive(:read).with('./Gemfile.lock').and_return(gemfile_lock_content)
28
31
  gem_spec = Rewriter::GemSpec.new('ast', '1.1.0')
29
32
  expect(gem_spec).to be_match
30
33
  end
31
34
 
32
35
  it 'returns false if version in Gemfile.lock is less than definition' do
33
- expect(File).to receive(:exists?).with('./Gemfile.lock').and_return(true)
36
+ expect(File).to receive(:exist?).with('./Gemfile.lock').and_return(true)
34
37
  expect(File).to receive(:read).with('./Gemfile.lock').and_return(gemfile_lock_content)
35
- gem_spec = Rewriter::GemSpec.new('ast', {gt: '1.2.0'})
38
+ gem_spec = Rewriter::GemSpec.new('ast', { gt: '1.2.0' })
36
39
  expect(gem_spec).not_to be_match
37
40
  end
38
41
 
39
42
  it 'returns false if gem does not exist in Gemfile.lock' do
40
- expect(File).to receive(:exists?).with('./Gemfile.lock').and_return(true)
43
+ expect(File).to receive(:exist?).with('./Gemfile.lock').and_return(true)
41
44
  expect(File).to receive(:read).with('./Gemfile.lock').and_return(gemfile_lock_content)
42
45
  gem_spec = Rewriter::GemSpec.new('synvert', '1.0.0')
43
46
  expect(gem_spec).not_to be_match
44
47
  end
45
48
 
46
49
  it 'raise Synvert::Core::GemfileLockNotFound if Gemfile.lock does not exist' do
47
- expect(File).to receive(:exists?).with('./Gemfile.lock').and_return(false)
50
+ expect(File).to receive(:exist?).with('./Gemfile.lock').and_return(false)
48
51
  gem_spec = Rewriter::GemSpec.new('ast', '1.1.0')
49
- expect { gem_spec.match? }.to raise_error(Synvert::Core::GemfileLockNotFound)
52
+ expect(gem_spec).to be_match
50
53
  end
51
54
  end
52
55
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Synvert::Core
@@ -5,74 +7,77 @@ module Synvert::Core
5
7
  let(:dummy_instance) { Class.new { include Rewriter::Helper }.new }
6
8
  let(:instance) do
7
9
  rewriter = Rewriter.new('foo', 'bar')
8
- Rewriter::Instance.new rewriter, 'spec/**/*_spec.rb' do; end
10
+ Rewriter::Instance.new rewriter, 'spec/**/*_spec.rb' do
11
+ end
9
12
  end
10
13
 
11
- describe "add_receiver_if_necessary" do
12
- context "with receiver" do
13
- let(:node) { parse("User.save(false)") }
14
+ describe 'add_receiver_if_necessary' do
15
+ context 'with receiver' do
16
+ let(:node) { parse('User.save(false)') }
14
17
 
15
- it "adds reciever" do
18
+ it 'adds reciever' do
16
19
  allow(dummy_instance).to receive(:node).and_return(node)
17
- expect(dummy_instance.add_receiver_if_necessary("save(validate: false)")).to eq "{{receiver}}.save(validate: false)"
20
+ expect(
21
+ dummy_instance.add_receiver_if_necessary('save(validate: false)')
22
+ ).to eq '{{receiver}}.save(validate: false)'
18
23
  end
19
24
  end
20
25
 
21
- context "without receiver" do
22
- let(:node) { parse("save(false)") }
26
+ context 'without receiver' do
27
+ let(:node) { parse('save(false)') }
23
28
 
24
29
  it "doesn't add reciever" do
25
30
  allow(dummy_instance).to receive(:node).and_return(node)
26
- expect(dummy_instance.add_receiver_if_necessary("save(validate: false)")).to eq "save(validate: false)"
31
+ expect(dummy_instance.add_receiver_if_necessary('save(validate: false)')).to eq 'save(validate: false)'
27
32
  end
28
33
  end
29
34
  end
30
35
 
31
- describe "add_arguments_with_parenthesis_if_necessary" do
32
- context "with arguments" do
33
- let(:node) { parse("user.save(false)") }
36
+ describe 'add_arguments_with_parenthesis_if_necessary' do
37
+ context 'with arguments' do
38
+ let(:node) { parse('user.save(false)') }
34
39
 
35
- it "gets arguments with parenthesis" do
40
+ it 'gets arguments with parenthesis' do
36
41
  allow(dummy_instance).to receive(:node).and_return(node)
37
- expect(dummy_instance.add_arguments_with_parenthesis_if_necessary).to eq "({{arguments}})"
42
+ expect(dummy_instance.add_arguments_with_parenthesis_if_necessary).to eq '({{arguments}})'
38
43
  end
39
44
  end
40
45
 
41
- context "without argument" do
42
- let(:node) { parse("user.save") }
46
+ context 'without argument' do
47
+ let(:node) { parse('user.save') }
43
48
 
44
- it "gets nothing" do
49
+ it 'gets nothing' do
45
50
  allow(dummy_instance).to receive(:node).and_return(node)
46
- expect(dummy_instance.add_arguments_with_parenthesis_if_necessary).to eq ""
51
+ expect(dummy_instance.add_arguments_with_parenthesis_if_necessary).to eq ''
47
52
  end
48
53
  end
49
54
  end
50
55
 
51
- describe "add_curly_brackets_if_necessary" do
52
- it "add {} if code does not have" do
53
- expect(dummy_instance.add_curly_brackets_if_necessary("foo: bar")).to eq "{ foo: bar }"
56
+ describe 'add_curly_brackets_if_necessary' do
57
+ it 'add {} if code does not have' do
58
+ expect(dummy_instance.add_curly_brackets_if_necessary('foo: bar')).to eq '{ foo: bar }'
54
59
  end
55
60
 
56
61
  it "doesn't add {} if code already has" do
57
- expect(dummy_instance.add_curly_brackets_if_necessary("{foo: bar}")).to eq "{foo: bar}"
62
+ expect(dummy_instance.add_curly_brackets_if_necessary('{foo: bar}')).to eq '{foo: bar}'
58
63
  end
59
64
  end
60
65
 
61
- describe "strip_brackets" do
62
- it "strip ()" do
63
- expect(dummy_instance.strip_brackets("(123)")).to eq "123"
66
+ describe 'strip_brackets' do
67
+ it 'strip ()' do
68
+ expect(dummy_instance.strip_brackets('(123)')).to eq '123'
64
69
  end
65
70
 
66
- it "strip {}" do
67
- expect(dummy_instance.strip_brackets("{123}")).to eq "123"
71
+ it 'strip {}' do
72
+ expect(dummy_instance.strip_brackets('{123}')).to eq '123'
68
73
  end
69
74
 
70
- it "strip []" do
71
- expect(dummy_instance.strip_brackets("[123]")).to eq "123"
75
+ it 'strip []' do
76
+ expect(dummy_instance.strip_brackets('[123]')).to eq '123'
72
77
  end
73
78
 
74
- it "not strip unmatched (]" do
75
- expect(dummy_instance.strip_brackets("(123]")).to eq "(123]"
79
+ it 'not strip unmatched (]' do
80
+ expect(dummy_instance.strip_brackets('(123]')).to eq '(123]'
76
81
  end
77
82
  end
78
83
  end