File: version.bats

package info (click to toggle)
ruby-build 20200401-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,304 kB
  • sloc: sh: 1,777; ruby: 18; makefile: 9
file content (39 lines) | stat: -rw-r--r-- 1,086 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bats

load test_helper

bats_bin="${BATS_TEST_DIRNAME}/../bin/ruby-build"
static_version="$(grep VERSION "$bats_bin" | head -1 | cut -d'"' -f 2)"

@test "ruby-build static version" {
  stub git 'echo "ASPLODE" >&2; exit 1'
  run ruby-build --version
  assert_success "ruby-build ${static_version}"
  unstub git
}

@test "ruby-build git version" {
  stub git \
    'remote -v : echo origin https://github.com/rbenv/ruby-build.git' \
    "describe --tags HEAD : echo v1984-12-gSHA"
  run ruby-build --version
  assert_success "ruby-build 1984-12-gSHA"
  unstub git
}

@test "git describe fails" {
  stub git \
    'remote -v : echo origin https://github.com/rbenv/ruby-build.git' \
    "describe --tags HEAD : echo ASPLODE >&2; exit 1"
  run ruby-build --version
  assert_success "ruby-build ${static_version}"
  unstub git
}

@test "git remote doesn't match" {
  stub git \
    'remote -v : echo origin https://github.com/Homebrew/homebrew.git' \
    "describe --tags HEAD : echo v1984-12-gSHA"
  run ruby-build --version
  assert_success "ruby-build ${static_version}"
}