vim-flavor 1.1.5 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/features/.nav +6 -0
  4. data/features/branches/README.md +12 -0
  5. data/features/branches/changing_tracking_branches.feature +78 -0
  6. data/features/branches/detect_incompatible_declarations.feature +72 -0
  7. data/features/branches/install.feature +51 -0
  8. data/features/branches/upgrade.feature +30 -0
  9. data/features/install_vim_flavor.md +1 -1
  10. data/features/news.md +10 -0
  11. data/features/philosophy.md +22 -1
  12. data/features/resolve_dependencies/basics.feature +0 -32
  13. data/features/step_definitions/flavor_steps.rb +10 -0
  14. data/features/support/env.rb +7 -1
  15. data/features/version_lock.feature +1 -20
  16. data/features/version_tag_format.feature +44 -8
  17. data/lib/vim-flavor.rb +2 -0
  18. data/lib/vim-flavor/branchversion.rb +28 -0
  19. data/lib/vim-flavor/facade.rb +7 -3
  20. data/lib/vim-flavor/flavor.rb +20 -5
  21. data/lib/vim-flavor/flavorfile.rb +13 -12
  22. data/lib/vim-flavor/lockfileparser.rb +18 -4
  23. data/lib/vim-flavor/plainversion.rb +28 -0
  24. data/lib/vim-flavor/version.rb +10 -17
  25. data/lib/vim-flavor/versionconstraint.rb +23 -7
  26. data/spec/branchversion_spec.rb +50 -0
  27. data/spec/enumerableextension_spec.rb +4 -4
  28. data/spec/facade_spec.rb +2 -2
  29. data/spec/flavor_spec.rb +9 -8
  30. data/spec/flavorfile_spec.rb +44 -25
  31. data/spec/lockfile_spec.rb +58 -23
  32. data/spec/plainversion_spec.rb +75 -0
  33. data/spec/spec_helper.rb +10 -0
  34. data/spec/stringextension_spec.rb +4 -3
  35. data/spec/version_spec.rb +33 -51
  36. data/spec/versionconstraint_spec.rb +81 -26
  37. data/vim-flavor.gemspec +1 -0
  38. metadata +35 -3
@@ -12,7 +12,7 @@ module Vim
12
12
  xs << "each #{n}"
13
13
  end
14
14
 
15
- xs.should == [
15
+ expect(xs).to be == [
16
16
  "before_each 1",
17
17
  "each 1",
18
18
  "before_each 2",
@@ -32,7 +32,7 @@ module Vim
32
32
  xs << "each #{n}"
33
33
  end
34
34
 
35
- xs.should == [
35
+ expect(xs).to be == [
36
36
  "each 1",
37
37
  "after_each 1",
38
38
  "each 2",
@@ -57,7 +57,7 @@ module Vim
57
57
  end
58
58
  }.to raise_error(RuntimeError, 'bang! 3')
59
59
 
60
- xs.should == [
60
+ expect(xs).to be == [
61
61
  "each enter 1",
62
62
  "each leave 1",
63
63
  "each enter 2",
@@ -86,7 +86,7 @@ module Vim
86
86
  end
87
87
  }.to raise_error(RuntimeError, 'bang!')
88
88
 
89
- xs.should == [
89
+ expect(xs).to be == [
90
90
  "each enter 1",
91
91
  "each leave 1",
92
92
  "each enter 2",
data/spec/facade_spec.rb CHANGED
@@ -17,7 +17,7 @@ module Vim
17
17
  flavors_path = @tmp_path.to_vimfiles_path.to_flavors_path
18
18
  Facade.new().create_vim_script_for_bootstrap(flavors_path)
19
19
 
20
- File.should exist(flavors_path.to_bootstrap_path)
20
+ expect(File).to exist(flavors_path.to_bootstrap_path)
21
21
 
22
22
  _rtp = %x{
23
23
  for plugin_name in 'foo' 'bar' 'baz'
@@ -40,7 +40,7 @@ module Vim
40
40
  _rtp.
41
41
  split(/[\r\n]/).
42
42
  select {|p| p != ''}
43
- rtps.should == [
43
+ expect(rtps).to be == [
44
44
  '!',
45
45
  '!/flavors/bar',
46
46
  '!/flavors/baz',
data/spec/flavor_spec.rb CHANGED
@@ -6,7 +6,8 @@ module Vim
6
6
  describe '#versions_from_tags' do
7
7
  def example tags, versions
8
8
  f = Flavor.new()
9
- f.versions_from_tags(tags).sort.map(&:version).should == versions
9
+ expect(f.versions_from_tags(tags).sort.map(&:version)).to be ==
10
+ versions
10
11
  end
11
12
 
12
13
  it 'converts tags into versions' do
@@ -34,15 +35,15 @@ module Vim
34
35
  Version.create(s)
35
36
  end
36
37
 
37
- it {should be_satisfied_with version('1.2.3')}
38
+ it {is_expected.to be_satisfied_with version('1.2.3')}
38
39
 
39
- it {should be_satisfied_with version('1.2.4')}
40
- it {should be_satisfied_with version('1.3.3')}
41
- it {should be_satisfied_with version('2.2.3')}
40
+ it {is_expected.to be_satisfied_with version('1.2.4')}
41
+ it {is_expected.to be_satisfied_with version('1.3.3')}
42
+ it {is_expected.to be_satisfied_with version('2.2.3')}
42
43
 
43
- it {should_not be_satisfied_with version('0.2.3')}
44
- it {should_not be_satisfied_with version('1.1.3')}
45
- it {should_not be_satisfied_with version('1.2.2')}
44
+ it {is_expected.not_to be_satisfied_with version('0.2.3')}
45
+ it {is_expected.not_to be_satisfied_with version('1.1.3')}
46
+ it {is_expected.not_to be_satisfied_with version('1.2.2')}
46
47
  end
47
48
  end
48
49
  end
@@ -3,48 +3,52 @@ require 'spec_helper'
3
3
  module Vim
4
4
  module Flavor
5
5
  describe FlavorFile do
6
+ def constraint(*args)
7
+ VersionConstraint.new(*args)
8
+ end
9
+
6
10
  describe '#flavor' do
7
11
  let(:ff) {FlavorFile.new()}
8
12
 
9
- context 'basics' do
13
+ context 'with basic usage' do
10
14
  it 'registers a flavor' do
11
15
  ff.flavor 'kana/vim-altr', '>= 1.2.3'
12
16
  f = ff.flavor_table['kana/vim-altr']
13
- f.repo_name.should == 'kana/vim-altr'
14
- f.version_constraint.should == VersionConstraint.new('>= 1.2.3')
17
+ expect(f.repo_name).to be == 'kana/vim-altr'
18
+ expect(f.version_constraint).to be == constraint('>= 1.2.3')
15
19
  end
16
20
 
17
- it 'completes version constraint if it is not given' do
21
+ it 'completes a version constraint if it is not given' do
18
22
  ff.flavor 'kana/vim-altr'
19
23
  f = ff.flavor_table['kana/vim-altr']
20
- f.repo_name.should == 'kana/vim-altr'
21
- f.version_constraint.should == VersionConstraint.new('>= 0')
24
+ expect(f.repo_name).to be == 'kana/vim-altr'
25
+ expect(f.version_constraint).to be == constraint('>= 0')
22
26
  end
23
27
  end
24
28
 
25
- context 'group option' do
29
+ context 'with a group option' do
26
30
  it 'supports a group option with a version constraint' do
27
31
  ff.flavor 'kana/vim-vspec', '~> 1.0', :group => :development
28
32
  f = ff.flavor_table['kana/vim-vspec']
29
- f.version_constraint.should == VersionConstraint.new('~> 1.0')
30
- f.group.should == :development
33
+ expect(f.version_constraint).to be == constraint('~> 1.0')
34
+ expect(f.group).to be == :development
31
35
  end
32
36
 
33
37
  it 'supports a group option without version constraint' do
34
38
  ff.flavor 'kana/vim-vspec', :group => :development
35
39
  f = ff.flavor_table['kana/vim-vspec']
36
- f.version_constraint.should == VersionConstraint.new('>= 0')
37
- f.group.should == :development
40
+ expect(f.version_constraint).to be == constraint('>= 0')
41
+ expect(f.group).to be == :development
38
42
  end
39
43
 
40
44
  it 'uses :default as the default group' do
41
45
  ff.flavor 'kana/vim-vspec'
42
46
  f = ff.flavor_table['kana/vim-vspec']
43
- f.group.should == :runtime
47
+ expect(f.group).to be == :runtime
44
48
  end
45
49
  end
46
50
 
47
- context 'group block' do
51
+ context 'in a group block' do
48
52
  it 'changes the default group for flavors in a given block' do
49
53
  ff.flavor 'a'
50
54
  ff.group :outer do
@@ -56,11 +60,11 @@ module Vim
56
60
  end
57
61
  ff.flavor 'e'
58
62
 
59
- ff.flavor_table['a'].group.should == :runtime
60
- ff.flavor_table['b'].group.should == :outer
61
- ff.flavor_table['c'].group.should == :inner
62
- ff.flavor_table['d'].group.should == :outer
63
- ff.flavor_table['e'].group.should == :runtime
63
+ expect(ff.flavor_table['a'].group).to be == :runtime
64
+ expect(ff.flavor_table['b'].group).to be == :outer
65
+ expect(ff.flavor_table['c'].group).to be == :inner
66
+ expect(ff.flavor_table['d'].group).to be == :outer
67
+ expect(ff.flavor_table['e'].group).to be == :runtime
64
68
  end
65
69
 
66
70
  it 'restores the default group even if an exception is raised' do
@@ -78,11 +82,26 @@ module Vim
78
82
  end
79
83
  ff.flavor 'e'
80
84
 
81
- ff.flavor_table['a'].group.should == :runtime
82
- ff.flavor_table['b'].group.should == :outer
83
- ff.flavor_table['c'].should be_nil
84
- ff.flavor_table['d'].group.should == :outer
85
- ff.flavor_table['e'].group.should == :runtime
85
+ expect(ff.flavor_table['a'].group).to be == :runtime
86
+ expect(ff.flavor_table['b'].group).to be == :outer
87
+ expect(ff.flavor_table['c']).to be_nil
88
+ expect(ff.flavor_table['d'].group).to be == :outer
89
+ expect(ff.flavor_table['e'].group).to be == :runtime
90
+ end
91
+ end
92
+
93
+ context 'with a branch option' do
94
+ it 'is supported' do
95
+ ff.flavor 'kana/vim-altr', branch: 'master'
96
+ f = ff.flavor_table['kana/vim-altr']
97
+ expect(f.repo_name).to be == 'kana/vim-altr'
98
+ expect(f.version_constraint).to be == constraint('branch: master')
99
+ end
100
+
101
+ it 'cannot be used with a version constraint' do
102
+ expect {
103
+ ff.flavor 'kana/vim-altr', '>= 0', branch: 'master'
104
+ }.to raise_error(/branch cannot be used with a version constraint/)
86
105
  end
87
106
  end
88
107
  end
@@ -102,8 +121,8 @@ module Vim
102
121
  end
103
122
  ff = FlavorFile.load(flavorfile_path)
104
123
  f = ff.flavor_table['kana/vim-altr']
105
- f.repo_name.should == 'kana/vim-altr'
106
- f.version_constraint.should == VersionConstraint.new('~> 1.2')
124
+ expect(f.repo_name).to be == 'kana/vim-altr'
125
+ expect(f.version_constraint).to be == constraint('~> 1.2')
107
126
  end
108
127
  end
109
128
  end
@@ -14,30 +14,41 @@ module Vim
14
14
  def flavor(repo_name, locked_version)
15
15
  f = Flavor.new()
16
16
  f.repo_name = repo_name
17
- f.locked_version = version(locked_version)
17
+ f.locked_version = v(locked_version)
18
18
  f
19
19
  end
20
20
 
21
- def version(s)
21
+ def v(s)
22
22
  Version.create(s)
23
23
  end
24
24
 
25
- it 'has flavors sorted by repo_name' do
26
- l = LockFile.new(@tmp_path.to_lockfile_path)
27
- foo = flavor('foo', '1.2.3')
28
- bar = flavor('bar', '2.3.4')
29
- baz = flavor('baz', '3.4.5')
30
- [foo, bar, baz].each do |f|
31
- l.flavor_table[f.repo_name] = f
32
- end
25
+ describe '#flavors' do
26
+ it 'is sorted by repo_name' do
27
+ l = LockFile.new(@tmp_path.to_lockfile_path)
28
+ foo = flavor('foo', '1.2.3')
29
+ bar = flavor('bar', '2.3.4')
30
+ baz = flavor('baz', '3.4.5')
31
+ [foo, bar, baz].each do |f|
32
+ l.flavor_table[f.repo_name] = f
33
+ end
33
34
 
34
- l.flavors.should == [bar, baz, foo]
35
+ expect(l.flavors).to be == [bar, baz, foo]
36
+ end
35
37
  end
36
38
 
37
39
  describe '::serialize_lock_status' do
38
40
  it 'converts a flavor into an array of lines' do
39
- LockFile.serialize_lock_status(flavor('foo', '1.2.3')).should ==
40
- ['foo (1.2.3)']
41
+ expect(
42
+ LockFile.serialize_lock_status(flavor('foo', '1.2.3'))
43
+ ).to be == ['foo (1.2.3)']
44
+ end
45
+
46
+ it 'supports a flavor locked to a branch' do
47
+ expect(
48
+ LockFile.serialize_lock_status(
49
+ flavor('foo', branch: 'master', revision: '1' * 40)
50
+ )
51
+ ).to be == ["foo (#{'1' * 40} at master)"]
41
52
  end
42
53
  end
43
54
 
@@ -52,15 +63,39 @@ module Vim
52
63
  end
53
64
 
54
65
  l = LockFile.new(@tmp_path.to_lockfile_path)
55
- l.flavor_table.should be_empty
66
+ expect(l.flavor_table).to be_empty
67
+
68
+ l.load()
69
+ expect(l.flavor_table['foo'].repo_name).to be == 'foo'
70
+ expect(l.flavor_table['foo'].locked_version).to be == v('1.2.3')
71
+ expect(l.flavor_table['bar'].repo_name).to be == 'bar'
72
+ expect(l.flavor_table['bar'].locked_version).to be == v('2.3.4')
73
+ expect(l.flavor_table['baz'].repo_name).to be == 'baz'
74
+ expect(l.flavor_table['baz'].locked_version).to be == v('3.4.5')
75
+ end
76
+
77
+ it 'recognizes flavors with BranchVersion' do
78
+ File.open(@tmp_path.to_lockfile_path, 'w') do |io|
79
+ io.write(<<-"END")
80
+ foo (#{'1' * 40} at master)
81
+ bar (#{'2' * 40} at experimental)
82
+ baz (#{'3' * 40} at stable)
83
+ END
84
+ end
85
+
86
+ l = LockFile.new(@tmp_path.to_lockfile_path)
87
+ expect(l.flavor_table).to be_empty
56
88
 
57
89
  l.load()
58
- l.flavor_table['foo'].repo_name.should == 'foo'
59
- l.flavor_table['foo'].locked_version.should == version('1.2.3')
60
- l.flavor_table['bar'].repo_name.should == 'bar'
61
- l.flavor_table['bar'].locked_version.should == version('2.3.4')
62
- l.flavor_table['baz'].repo_name.should == 'baz'
63
- l.flavor_table['baz'].locked_version.should == version('3.4.5')
90
+ expect(l.flavor_table['foo'].repo_name).to be == 'foo'
91
+ expect(l.flavor_table['foo'].locked_version).to be ==
92
+ v(branch: 'master', revision: '1' * 40)
93
+ expect(l.flavor_table['bar'].repo_name).to be == 'bar'
94
+ expect(l.flavor_table['bar'].locked_version).to be ==
95
+ v(branch: 'experimental', revision: '2' * 40)
96
+ expect(l.flavor_table['baz'].repo_name).to be == 'baz'
97
+ expect(l.flavor_table['baz'].locked_version).to be ==
98
+ v(branch: 'stable', revision: '3' * 40)
64
99
  end
65
100
  end
66
101
 
@@ -73,13 +108,13 @@ module Vim
73
108
  end
74
109
 
75
110
  l = LockFile.load_or_new(@tmp_path.to_lockfile_path)
76
- l.flavor_table['foo'].repo_name.should == 'foo'
77
- l.flavor_table['foo'].locked_version.should == version('1.2.3')
111
+ expect(l.flavor_table['foo'].repo_name).to be == 'foo'
112
+ expect(l.flavor_table['foo'].locked_version).to be == v('1.2.3')
78
113
  end
79
114
 
80
115
  it 'only creates a new instance if a given path does not exist' do
81
116
  l = LockFile.load_or_new(@tmp_path.to_lockfile_path)
82
- l.flavor_table.should be_empty
117
+ expect(l.flavor_table).to be_empty
83
118
  end
84
119
  end
85
120
  end
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+
3
+ module Vim
4
+ module Flavor
5
+ describe PlainVersion do
6
+ v = described_class
7
+
8
+ describe '::create' do
9
+ it 'accept "X.Y.Z" style tags' do
10
+ expect {
11
+ v.create('1')
12
+ v.create('1.2')
13
+ v.create('1.2.3')
14
+ }.not_to raise_error
15
+ end
16
+
17
+ it 'accept "vX.Y.Z" style tags' do
18
+ expect {
19
+ v.create('v1')
20
+ v.create('v1.2')
21
+ v.create('v1.2.3')
22
+ }.not_to raise_error
23
+ end
24
+ end
25
+
26
+ describe '::correct?' do
27
+ it 'accept "X.Y.Z" style tags' do
28
+ expect(v.correct?('1')).to be_true
29
+ expect(v.correct?('1.2')).to be_true
30
+ expect(v.correct?('1.2.3')).to be_true
31
+ end
32
+
33
+ it 'accept "vX.Y.Z" style tags' do
34
+ expect(v.correct?('v1')).to be_true
35
+ expect(v.correct?('v1.2')).to be_true
36
+ expect(v.correct?('v1.2.3')).to be_true
37
+ end
38
+ end
39
+
40
+ describe '#<=>' do
41
+ it 'can comapre "X.Y.Z" tags' do
42
+ expect(v.create('1.2.3')).to be <= v.create('1.3')
43
+ expect(v.create('1.2.3')).to be == v.create('1.2.3')
44
+ expect(v.create('1.2.3')).to be >= v.create('1.1')
45
+ end
46
+
47
+ it 'can comapre "vX.Y.Z" tags' do
48
+ expect(v.create('v1.2.3')).to be <= v.create('v1.3')
49
+ expect(v.create('v1.2.3')).to be == v.create('v1.2.3')
50
+ expect(v.create('v1.2.3')).to be >= v.create('v1.1')
51
+ end
52
+
53
+ it 'can comapre "X.Y.Z" tag with "vX.Y.Z" tag' do
54
+ expect(v.create('1.2.3')).to be <= v.create('v1.3')
55
+ expect(v.create('1.2.3')).to be == v.create('v1.2.3')
56
+ expect(v.create('1.2.3')).to be >= v.create('v1.1')
57
+ end
58
+ end
59
+
60
+ describe '#to_s' do
61
+ it 'is converted into the original string' do
62
+ expect(v.create('1.2.3').to_s).to be == '1.2.3'
63
+ expect(v.create('v1.2.3').to_s).to be == 'v1.2.3'
64
+ end
65
+ end
66
+
67
+ describe '#to_revision' do
68
+ it 'returns the revision corresponding to a version' do
69
+ expect(v.create('1.2.3').to_revision).to be == '1.2.3'
70
+ expect(v.create('v1.2.3').to_revision).to be == 'v1.2.3'
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,12 @@
1
1
  require 'bundler/setup'
2
2
  require 'vim-flavor'
3
+
4
+ module OneLinerExpectSyntax
5
+ def is_expected
6
+ expect(subject)
7
+ end
8
+ end
9
+
10
+ RSpec.configure do |rspec|
11
+ rspec.include OneLinerExpectSyntax
12
+ end
@@ -5,9 +5,10 @@ module Vim
5
5
  describe StringExtension do
6
6
  describe '#zap' do
7
7
  it 'replace unsafe characters with "_"' do
8
- 'fakeclip'.zap.should == 'fakeclip'
9
- 'kana/vim-altr'.zap.should == 'kana_vim-altr'
10
- 'git://example.com/foo.git'.zap.should == 'git___example.com_foo.git'
8
+ expect('fakeclip'.zap).to be == 'fakeclip'
9
+ expect('kana/vim-altr'.zap).to be == 'kana_vim-altr'
10
+ expect('git://example.com/foo.git'.zap).to be ==
11
+ 'git___example.com_foo.git'
11
12
  end
12
13
  end
13
14
  end
data/spec/version_spec.rb CHANGED
@@ -3,62 +3,44 @@ require 'spec_helper'
3
3
  module Vim
4
4
  module Flavor
5
5
  describe Version do
6
- describe '::create' do
7
- it 'accept "X.Y.Z" style tags' do
8
- expect {
9
- Version.create('1')
10
- Version.create('1.2')
11
- Version.create('1.2.3')
12
- }.not_to raise_error
13
- end
6
+ v = described_class
14
7
 
15
- it 'accept "vX.Y.Z" style tags' do
16
- expect {
17
- Version.create('v1')
18
- Version.create('v1.2')
19
- Version.create('v1.2.3')
20
- }.not_to raise_error
8
+ describe '::create' do
9
+ context 'with a string' do
10
+ it 'makes a PlainVersion' do
11
+ expect(v.create('1.2.3')).to be_a(PlainVersion)
12
+ expect(v.create('v1.2.3')).to be_a(PlainVersion)
13
+ end
14
+ end
15
+
16
+ context 'with a branch' do
17
+ it 'makes a BranchVersion' do
18
+ r = v.create(branch: 'master')
19
+ expect(r).to be_a(BranchVersion)
20
+ expect(r.branch).to be == 'master'
21
+ expect(r.revision).to be_nil
22
+ end
23
+ end
24
+
25
+ context 'with a branch and a ref' do
26
+ it 'makes a BranchVersion' do
27
+ r = v.create(branch: 'master', revision: '1' * 40)
28
+ expect(r).to be_a(BranchVersion)
29
+ expect(r.branch).to be == 'master'
30
+ expect(r.revision).to be == '1' * 40
31
+ end
21
32
  end
22
33
  end
23
34
 
24
35
  describe '::correct?' do
25
- it 'accept "X.Y.Z" style tags' do
26
- Version.correct?('1').should be_true
27
- Version.correct?('1.2').should be_true
28
- Version.correct?('1.2.3').should be_true
29
- end
30
-
31
- it 'accept "vX.Y.Z" style tags' do
32
- Version.correct?('v1').should be_true
33
- Version.correct?('v1.2').should be_true
34
- Version.correct?('v1.2.3').should be_true
35
- end
36
- end
37
-
38
- describe '#<=>' do
39
- it 'can comapre "X.Y.Z" tags' do
40
- Version.create('1.2.3').should be <= Version.create('1.3')
41
- Version.create('1.2.3').should be == Version.create('1.2.3')
42
- Version.create('1.2.3').should be >= Version.create('1.1')
43
- end
44
-
45
- it 'can comapre "vX.Y.Z" tags' do
46
- Version.create('v1.2.3').should be <= Version.create('v1.3')
47
- Version.create('v1.2.3').should be == Version.create('v1.2.3')
48
- Version.create('v1.2.3').should be >= Version.create('v1.1')
49
- end
50
-
51
- it 'can comapre "X.Y.Z" tag with "vX.Y.Z" tag' do
52
- Version.create('1.2.3').should be <= Version.create('v1.3')
53
- Version.create('1.2.3').should be == Version.create('v1.2.3')
54
- Version.create('1.2.3').should be >= Version.create('v1.1')
55
- end
56
- end
57
-
58
- describe '#to_s' do
59
- it 'is converted into the original string' do
60
- Version.create('1.2.3').to_s.should == '1.2.3'
61
- Version.create('v1.2.3').to_s.should == 'v1.2.3'
36
+ it 'is an alias of PlainVersion::correct?' do
37
+ expect(v.correct?('1')).to be_true
38
+ expect(v.correct?('1.2')).to be_true
39
+ expect(v.correct?('1.2.3')).to be_true
40
+ expect(v.correct?('v1')).to be_true
41
+ expect(v.correct?('v1.2')).to be_true
42
+ expect(v.correct?('v1.2.3')).to be_true
43
+ expect(v.correct?('vim7.4')).to be_false
62
44
  end
63
45
  end
64
46
  end