bmp 1.2.0 → 1.3.1

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.
@@ -1,7 +1,14 @@
1
-
2
1
  require 'bump'
3
2
  require 'spec_helper'
4
3
 
5
4
  describe Bump::CLI do
5
+ describe '#main' do
6
+ it 'calls app.main' do
7
+ cli = Bump::CLI.new({})
8
+
9
+ expect(cli.app).to receive(:main).once
6
10
 
11
+ cli.main
12
+ end
13
+ end
7
14
  end
@@ -1,23 +1,16 @@
1
-
2
-
3
-
4
1
  describe Bump::Command do
2
+ describe '#exec' do
3
+ it 'prints and executes the command' do
4
+ logger = Bump::Logger.new
5
5
 
6
- describe '#exec' do
7
-
8
- it 'prints and executes the command' do
9
-
10
- logger = double()
6
+ comm = Bump::Command.new logger
11
7
 
12
- comm = Bump::Command.new logger
13
-
14
- expect(logger).to receive(:log).with "===> echo 1"
15
- expect(logger).to receive(:log).with "1\n"
16
-
17
- comm.exec "echo 1"
18
-
19
- end
8
+ expect(logger).to receive(:green).with('+echo 1').once
9
+ allow(logger).to receive(:green) { 'greened +echo 1' }
10
+ expect(logger).to receive(:log).with('greened +echo 1').once
11
+ expect(logger).to receive(:log).with("1\n", nil).once
20
12
 
13
+ comm.exec 'echo 1'
21
14
  end
22
-
15
+ end
23
16
  end
@@ -1,38 +1,31 @@
1
-
2
1
  require 'bump'
3
2
  require 'spec_helper'
4
3
 
5
4
  describe Bump::BumpInfoRepository do
5
+ describe '#from_file' do
6
+ it 'gets the bump info from the file' do
7
+ repo = Bump::BumpInfoRepository.new 'spec/fixture/bmp.yml'
6
8
 
7
- describe '#fromFile' do
8
-
9
- it 'gets the bump info from the file' do
10
-
11
- repo = Bump::BumpInfoRepository.new 'spec/fixture/bmp.yml'
12
-
13
- bumpInfo = repo.fromFile
14
-
15
- expect(bumpInfo.class).to eq Bump::BumpInfo
16
-
17
- end
9
+ bump_info = repo.from_file
18
10
 
11
+ expect(bump_info.class).to eq Bump::BumpInfo
19
12
  end
13
+ end
20
14
 
21
- describe '#save' do
22
-
23
- it 'saves the current info to the file' do
15
+ describe '#save' do
16
+ it 'saves the current info to the file' do
17
+ repo = Bump::BumpInfoRepository.new 'spec/fixture/bmp.yml'
24
18
 
25
- repo = Bump::BumpInfoRepository.new 'spec/fixture/bmp.yml'
19
+ bump_info = repo.from_file
20
+ bump_info = Bump::BumpInfo.new Bump::VersionNumber.new(1, 2, 4), bump_info.files, bump_info.commit
26
21
 
27
- bumpInfo = repo.fromFile
28
- bumpInfo = Bump::BumpInfo.new Bump::VersionNumber.new(1, 2, 4), bumpInfo.files, bumpInfo.commit
22
+ repo = Bump::BumpInfoRepository.new 'spec/fixture/tmp_bmp.yml'
23
+ repo.save bump_info
29
24
 
30
- repo.save bumpInfo
25
+ bump_info = repo.from_file
26
+ expect(bump_info.version.to_s).to eq '1.2.4'
31
27
 
32
- bumpInfo = repo.fromFile
33
- expect(bumpInfo.version.to_s).to eq '1.2.4'
34
-
35
- end
28
+ File.delete 'spec/fixture/tmp_bmp.yml'
36
29
  end
37
-
30
+ end
38
31
  end
@@ -1,50 +1,74 @@
1
-
2
1
  require 'bump'
3
2
  require 'spec_helper'
4
3
 
5
4
  describe Bump::BumpInfo do
5
+ before :each do
6
+ @info = Bump::BumpInfo.new Bump::VersionNumber.new(1, 2, 3), { 'README.md' => 'v%.%.%', 'package.json' => 'v%.%.%' }, nil
7
+ end
6
8
 
7
- before :each do
8
-
9
- @info = Bump::BumpInfo.new Bump::VersionNumber.new(1, 2, 3), { "README.md" => "v%.%.%", "package.json" => "v%.%.%" }, nil
9
+ describe '#commit_message' do
10
+ it 'gets the commit message' do
11
+ @info = Bump::BumpInfo.new Bump::VersionNumber.new(1, 2, 3), { 'README.md' => 'v%.%.%', 'package.json' => 'v%.%.%' }, 'chore(bump): v%.%.%'
10
12
 
13
+ expect(@info.commit_message).to eq 'chore(bump): v1.2.3'
11
14
  end
15
+ end
12
16
 
13
- describe '#version' do
14
-
15
- it 'returns the version object' do
17
+ describe '#bump' do
18
+ it 'bumps the version with the give level' do
19
+ @info.bump :patch
20
+ expect(@info.version.to_s).to eq '1.2.4'
16
21
 
17
- expect(@info.version.class).to eq Bump::VersionNumber
18
- expect(@info.version.to_s).to eq '1.2.3'
19
-
20
- end
22
+ @info.bump :minor
23
+ expect(@info.version.to_s).to eq '1.3.0'
21
24
 
25
+ @info.bump :major
26
+ expect(@info.version.to_s).to eq '2.0.0'
22
27
  end
28
+ end
23
29
 
24
- describe '#files' do
30
+ describe '#preid=' do
31
+ it 'sets the preid' do
32
+ @info.preid = 'beta.1'
25
33
 
26
- it 'returns the hash of the files' do
34
+ expect(@info.version.to_s).to eq '1.2.3-beta.1'
35
+ end
36
+ end
37
+
38
+ describe '#update_rules' do
39
+ it 'gets the file update rules' do
40
+ expect(@info.update_rules.class).to eq Array
41
+ expect(@info.update_rules.size).to eq 2
42
+ expect(@info.update_rules[0].class).to eq Bump::FileUpdateRule
43
+ expect(@info.update_rules[1].class).to eq Bump::FileUpdateRule
44
+ end
45
+ end
27
46
 
28
- expect(@info.files).to eq({ "README.md" => "v%.%.%", "package.json" => "v%.%.%" })
47
+ describe '#perform_update' do
48
+ it 'performs the update on files' do
49
+ File.write 'spec/fixture/tmp_dummy.txt', File.read('spec/fixture/dummy.txt', encoding: Encoding::UTF_8)
29
50
 
30
- end
51
+ @info = Bump::BumpInfo.new Bump::VersionNumber.new(1, 2, 3, 'rc1'), { 'spec/fixture/tmp_dummy.txt' => 'v%.%.%' }, nil
31
52
 
32
- end
53
+ @info.bump :patch
33
54
 
34
- describe '#bump' do
55
+ @info.perform_update
35
56
 
36
- it 'bumps the version with the give level' do
57
+ expect(File.read('spec/fixture/tmp_dummy.txt', encoding: Encoding::UTF_8).strip).to eq 'dummy v1.2.4'
37
58
 
38
- @info.bump :patch
39
- expect(@info.version.to_s).to eq '1.2.4'
59
+ File.delete 'spec/fixture/tmp_dummy.txt'
60
+ end
61
+ end
40
62
 
41
- @info.bump :minor
42
- expect(@info.version.to_s).to eq '1.3.0'
63
+ describe '#valid?' do
64
+ it 'returns false if the files or petterns are unavailable' do
65
+ expect(@info.valid?).to be false
66
+ end
43
67
 
44
- @info.bump :major
45
- expect(@info.version.to_s).to eq '2.0.0'
68
+ it 'returns true if the files and patterns are available' do
69
+ @info = Bump::BumpInfo.new Bump::VersionNumber.new(1, 2, 3, 'rc1'), { 'spec/fixture/dummy.txt' => 'v%.%.%' }, nil
46
70
 
47
- end
71
+ expect(@info.valid?).to be true
48
72
  end
49
-
73
+ end
50
74
  end
@@ -1,37 +1,27 @@
1
-
2
1
  require 'bump'
3
2
  require 'spec_helper'
4
3
 
5
4
  describe Bump::FileUpdateRuleFactory do
5
+ describe 'self.create' do
6
+ it 'creates a FileUpdateRule if the give param is string' do
7
+ rule = Bump::FileUpdateRuleFactory.create 'README.md', 'v%.%.%', '1.2.3', '2.0.0'
6
8
 
7
- describe 'self.create' do
8
-
9
- it 'creates a FileUpdateRule if the give param is string' do
10
-
11
- rule = Bump::FileUpdateRuleFactory.create 'README.md', 'v%.%.%', '1.2.3', '2.0.0'
12
-
13
- expect(rule.class).to eq Bump::FileUpdateRule
14
-
15
- end
16
-
17
- it 'craetes a list of FileUpdateRules if the give param is an array of string' do
18
-
19
- rules = Bump::FileUpdateRuleFactory.create 'READEME.md', ['v%.%.%', 'w%.%.%'], '1.2.3', '2.0.0'
20
-
21
- expect(rules.class).to eq Array
22
- expect(rules[0].class).to eq Bump::FileUpdateRule
23
- expect(rules[1].class).to eq Bump::FileUpdateRule
24
- expect(rules.size).to eq 2
25
- end
26
-
27
- it 'creates a FileUpdateRule if the given param is not a string nor an array' do
9
+ expect(rule.class).to eq Bump::FileUpdateRule
10
+ end
28
11
 
29
- rule = Bump::FileUpdateRuleFactory.create 'READEME.md', nil, '1.2.3', '2.0.0'
12
+ it 'craetes a list of FileUpdateRules if the give param is an array of string' do
13
+ rules = Bump::FileUpdateRuleFactory.create 'READEME.md', ['v%.%.%', 'w%.%.%'], '1.2.3', '2.0.0'
30
14
 
31
- expect(rule.class).to eq Bump::FileUpdateRule
15
+ expect(rules.class).to eq Array
16
+ expect(rules[0].class).to eq Bump::FileUpdateRule
17
+ expect(rules[1].class).to eq Bump::FileUpdateRule
18
+ expect(rules.size).to eq 2
19
+ end
32
20
 
33
- end
21
+ it 'creates a FileUpdateRule if the given param is not a string nor an array' do
22
+ rule = Bump::FileUpdateRuleFactory.create 'READEME.md', nil, '1.2.3', '2.0.0'
34
23
 
24
+ expect(rule.class).to eq Bump::FileUpdateRule
35
25
  end
36
-
26
+ end
37
27
  end
@@ -2,49 +2,39 @@ require 'bump'
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Bump::FileUpdateRule do
5
+ before :each do
6
+ File.write 'spec/fixture/tmp_dummy.txt', File.read('spec/fixture/dummy.txt', encoding: Encoding::UTF_8)
5
7
 
6
- before :each do
7
- @rule = Bump::FileUpdateRule.new 'spec/fixture/dummy.txt', 'v%.%.%', '1.2.3', '2.0.0'
8
- end
9
-
10
- describe '#file' do
11
-
12
- it 'returns file property' do
13
-
14
- expect(@rule.file).to eq 'spec/fixture/dummy.txt'
8
+ @rule = Bump::FileUpdateRule.new 'spec/fixture/tmp_dummy.txt', 'v%.%.%', '1.2.3', '2.0.0'
9
+ end
15
10
 
16
- end
11
+ after :each do
12
+ File.delete 'spec/fixture/tmp_dummy.txt'
13
+ end
17
14
 
15
+ describe '#file_exists' do
16
+ it 'returns true if file exists' do
17
+ expect(@rule.file_exists).to be true
18
18
  end
19
19
 
20
- describe '#beforePattern' do
21
-
22
- it 'returns before_pattern property' do
23
-
24
- expect(@rule.beforePattern).to eq 'v1.2.3'
25
-
26
- end
20
+ it 'returns false if file does not exist' do
21
+ @rule = Bump::FileUpdateRule.new 'spec/fixture/doesnotexist.txt', 'v%.%.%', '1.2.3', '2.0.0'
27
22
 
23
+ expect(@rule.file_exists).to be false
28
24
  end
25
+ end
29
26
 
30
- describe '#afterPattern' do
31
-
32
- it 'returns before_pattern property' do
33
-
34
- expect(@rule.afterPattern).to eq 'v2.0.0'
35
-
36
- end
37
-
27
+ describe '#pattern_exists' do
28
+ it 'checks if the given pattern found in the file' do
29
+ expect(@rule.pattern_exists).to be true
38
30
  end
31
+ end
39
32
 
40
- describe '#patternExists' do
41
-
42
- it 'checks if the given pattern found in the file' do
43
-
44
- expect(@rule.patternExists).to be true
45
-
46
- end
33
+ describe '#perform' do
34
+ it 'performs the pattern replacement in the file' do
35
+ @rule.perform
47
36
 
37
+ expect(File.read('spec/fixture/tmp_dummy.txt', encoding: Encoding::UTF_8).strip).to eq 'dummy v2.0.0-rc1'
48
38
  end
49
-
39
+ end
50
40
  end
@@ -1,41 +1,18 @@
1
-
2
1
  require 'bump'
3
2
  require 'spec_helper'
4
3
 
5
4
  describe Bump::VersionNumberFactory do
5
+ describe '#from_string' do
6
+ it 'creates version object from version string' do
7
+ version = Bump::VersionNumberFactory.from_string '1.2.3-a'
6
8
 
7
- describe "#fromString" do
8
-
9
- it "creates version object from version string" do
10
-
11
- version = Bump::VersionNumberFactory.fromString "1.2.3-a"
12
-
13
- expect(version.to_s).to eq "1.2.3-a"
14
-
15
- version.bump :patch
16
-
17
- expect(version.to_s).to eq "1.2.4"
18
-
19
- version.bump :minor
20
-
21
- expect(version.to_s).to eq "1.3.0"
9
+ expect(version.to_s).to eq '1.2.3-a'
22
10
 
23
- version.bump :major
11
+ version = Bump::VersionNumberFactory.from_string '1.2.100-abc'
24
12
 
25
- expect(version.to_s).to eq "2.0.0"
26
-
27
- version.setPreid 'rc1'
28
-
29
- expect(version.to_s).to eq "2.0.0-rc1"
30
-
31
- version = Bump::VersionNumberFactory.fromString "1.2.100-abc"
32
-
33
- version.bump :patch
34
-
35
- expect(version.to_s).to eq "1.2.101"
36
-
37
- end
13
+ version.bump :patch
38
14
 
15
+ expect(version.to_s).to eq '1.2.101'
39
16
  end
40
-
17
+ end
41
18
  end
@@ -1,132 +1,80 @@
1
- # bump_spec.rb
2
-
3
1
  require 'bump'
4
2
  require 'spec_helper'
5
3
 
6
4
  describe Bump::VersionNumber do
5
+ describe '#to_s' do
6
+ it 'returns version string' do
7
+ # no suffix
8
+ version = Bump::VersionNumber.new 1, 2, 3
7
9
 
8
- describe "#to_s" do
9
-
10
- it "returns version string" do
11
-
12
- # no suffix
13
- version = Bump::VersionNumber.new 1, 2, 3
14
-
15
- expect(version.to_s).to eq '1.2.3'
16
-
17
- # with a suffix
18
- version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
19
-
20
- expect(version.to_s).to eq '1.2.3-rc1'
10
+ expect(version.to_s).to eq '1.2.3'
21
11
 
22
- end
12
+ # with a suffix
13
+ version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
23
14
 
15
+ expect(version.to_s).to eq '1.2.3-rc1'
24
16
  end
17
+ end
25
18
 
26
- describe "#bump :patch" do
27
-
28
- it "bumps patch level" do
29
-
30
- version = Bump::VersionNumber.new 1, 2, 3
31
-
32
- version.bump :patch
33
-
34
- expect(version.to_s).to eq '1.2.4'
35
-
36
- end
19
+ describe '#bump :patch' do
20
+ it 'bumps patch level' do
21
+ version = Bump::VersionNumber.new 1, 2, 3
37
22
 
38
- it "bumps 0.1.10 to 0.1.11" do
39
-
40
- version = Bump::VersionNumber.new 0, 1, 10
41
-
42
- version.bump :patch
43
-
44
- expect(version.to_s).to eq '0.1.11'
45
-
46
- end
47
-
48
- it "remove suffix if it is set" do
49
-
50
- version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
51
-
52
- version.bump :patch
53
-
54
- expect(version.to_s).to eq '1.2.4'
55
-
56
- end
23
+ version.bump :patch
57
24
 
25
+ expect(version.to_s).to eq '1.2.4'
58
26
  end
59
27
 
60
- describe "#bump :minor" do
61
-
62
- it "bumps patch level" do
28
+ it 'bumps 0.1.10 to 0.1.11' do
29
+ version = Bump::VersionNumber.new 0, 1, 10
63
30
 
64
- version = Bump::VersionNumber.new 1, 2, 3
65
-
66
- version.bump :minor
67
-
68
- expect(version.to_s).to eq '1.3.0'
69
-
70
- end
71
-
72
- it "remove suffix if it is set" do
73
-
74
- version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
75
-
76
- version.bump :minor
77
-
78
- expect(version.to_s).to eq '1.3.0'
79
-
80
- end
31
+ version.bump :patch
81
32
 
33
+ expect(version.to_s).to eq '0.1.11'
82
34
  end
83
35
 
84
- describe "#bump :major" do
85
-
86
- it "bumps patch level" do
87
-
88
- version = Bump::VersionNumber.new 1, 2, 3
89
-
90
- version.bump :major
36
+ it 'remove suffix if it is set' do
37
+ version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
91
38
 
92
- expect(version.to_s).to eq '2.0.0'
93
-
94
- end
95
-
96
- it "remove suffix if it is set" do
97
-
98
- version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
99
-
100
- version.bump :major
101
-
102
- expect(version.to_s).to eq '2.0.0'
103
-
104
- end
39
+ version.bump :patch
105
40
 
41
+ expect(version.to_s).to eq '1.2.4'
106
42
  end
43
+ end
107
44
 
108
- describe "#setPreid" do
45
+ describe '#bump :minor' do
46
+ it 'bumps patch level' do
47
+ version = Bump::VersionNumber.new 1, 2, 3
109
48
 
110
- it "sets the preid" do
49
+ version.bump :minor
111
50
 
112
- version = Bump::VersionNumber.new 1, 2, 3
51
+ expect(version.to_s).to eq '1.3.0'
52
+ end
113
53
 
114
- version.setPreid 'rc1'
54
+ it 'remove suffix if it is set' do
55
+ version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
115
56
 
116
- expect(version.to_s).to eq '1.2.3-rc1'
57
+ version.bump :minor
117
58
 
118
- end
59
+ expect(version.to_s).to eq '1.3.0'
60
+ end
61
+ end
119
62
 
120
- it "rewrite the preid if it is already set" do
63
+ describe '#bump :major' do
64
+ it 'bumps patch level' do
65
+ version = Bump::VersionNumber.new 1, 2, 3
121
66
 
122
- version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
67
+ version.bump :major
123
68
 
124
- version.setPreid 'rc2'
69
+ expect(version.to_s).to eq '2.0.0'
70
+ end
125
71
 
126
- expect(version.to_s).to eq '1.2.3-rc2'
72
+ it 'remove suffix if it is set' do
73
+ version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
127
74
 
128
- end
75
+ version.bump :major
129
76
 
77
+ expect(version.to_s).to eq '2.0.0'
130
78
  end
131
-
79
+ end
132
80
  end