File: test

package info (click to toggle)
ruby-vcr 6.0.0%2Breally5.0.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,320 kB
  • sloc: ruby: 8,456; sh: 177; makefile: 7
file content (43 lines) | stat: -rwxr-xr-x 719 bytes parent folder | download | duplicates (3)
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
40
41
42
43
#!/bin/bash
# Usage: script/test [FILES...]
set -e

filter() {
  local prefix="$1"
  shift 1
  ls -d "$@" | sed "s:$PWD/::" | grep "$prefix"
}

color() {
  if [ -t 1 ]; then
    printf "\e[%sm%s\e[m" "$1" "$2"
  else
    echo -n "$2"
  fi
}

run() {
  color "1;34" "> $*"; echo
  bundle exec "$@"
}

if [ $# -eq 0 ]; then
  specs=( spec/ )
  cukes=( features/ )
else
  specs=( $(filter ^spec "$@" || true) )
  cukes=( $(filter ^features "$@" 2>/dev/null || true) )

  if [ "${#specs[@]}" -eq 0 ] && [ "${#cukes[@]}" -eq 0 ]; then
    echo "Error: nothing to test." >&2
    exit 1
  fi
fi

if [ "${#specs[@]}" -gt 0 ]; then
  run rspec "${specs[@]}"
fi

if [ "${#cukes[@]}" -gt 0 ]; then
  run cucumber "${cukes[@]}"
fi