|
13 | 13 | end |
14 | 14 |
|
15 | 15 | describe '#version_from_git' do |
16 | | - it 'sets the version based on the git describe' do |
17 | | - proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform) |
18 | | - proj.instance_eval(project_block) |
| 16 | + let(:project) { Vanagon::Project::DSL.new('test-fixture', configdir, platform) } |
| 17 | + let(:repo) { double('repo') } |
| 18 | + subject { project._project } |
| 19 | + |
| 20 | + before(:each) do |
| 21 | + project.instance_eval(project_block) |
19 | 22 |
|
20 | | - # Lying is bad. You shouldn't lie. But sometimes when you're |
21 | | - # working with gross abstractions piled into the shape of |
22 | | - # an indescribable cyclopean obelisk, you might have to lie |
23 | | - # a little bit. Instead of trying to mock an entire Git instance, |
24 | | - # we'll just instantiate a Double and allow it to receive calls |
25 | | - # to .describe like it was a valid Git instance. |
26 | | - repo = double("repo") |
27 | 23 | expect(::Git) |
28 | 24 | .to receive(:open) |
29 | 25 | .and_return(repo) |
| 26 | + end |
30 | 27 |
|
| 28 | + it 'sets the version based on the git describe' do |
31 | 29 | allow(repo) |
32 | 30 | .to receive(:describe) |
33 | 31 | .and_return('1.2.3-1234') |
34 | 32 |
|
35 | | - proj.version_from_git |
36 | | - expect(proj._project.version).to eq('1.2.3.1234') |
| 33 | + project.version_from_git |
| 34 | + |
| 35 | + expect(subject.version).to eq('1.2.3.1234') |
37 | 36 | end |
| 37 | + |
38 | 38 | it 'sets the version based on the git describe with multiple dashes' do |
39 | | - proj = Vanagon::Project::DSL.new('test-fixture', configdir, platform) |
40 | | - proj.instance_eval(project_block) |
| 39 | + expect(repo) |
| 40 | + .to receive(:describe) |
| 41 | + .and_return('1.2.3---1234') |
41 | 42 |
|
42 | | - # See previous description of "indescribable cyclopean obelisk" |
43 | | - repo = double("repo") |
44 | | - expect(::Git) |
45 | | - .to receive(:open) |
46 | | - .and_return(repo) |
| 43 | + project.version_from_git |
| 44 | + |
| 45 | + expect(subject.version).to eq('1.2.3.1234') |
| 46 | + end |
| 47 | + |
| 48 | + %w[alpha1 beta2 rc0].each do |pre_release| |
| 49 | + it "munges tagged #{pre_release} pre-release versions to include a tilde" do |
| 50 | + expect(repo) |
| 51 | + .to receive(:describe) |
| 52 | + .and_return("1.2.3-#{pre_release}") |
47 | 53 |
|
| 54 | + project.version_from_git |
| 55 | + |
| 56 | + expect(subject.version).to eq("1.2.3~#{pre_release}") |
| 57 | + end |
| 58 | + end |
| 59 | + |
| 60 | + it "does not munge a tilde into un-tagged pre-release versions" do |
48 | 61 | expect(repo) |
49 | 62 | .to receive(:describe) |
50 | | - .and_return('1.2.3---1234') |
| 63 | + .and_return("1.2.3-beta10-42-gabcdef123") |
| 64 | + |
| 65 | + project.version_from_git |
51 | 66 |
|
52 | | - proj.version_from_git |
53 | | - expect(proj._project.version).to eq('1.2.3.1234') |
| 67 | + expect(subject.version).to eq("1.2.3.beta10.42.gabcdef123") |
54 | 68 | end |
55 | 69 | end |
56 | 70 |
|
|
0 commit comments