#!/bin/sh

# Test jgem functionality

set -e

# check if default local gems exist
# (specific gem not important)
jgem list | grep '^json'

# prepare a writable GEM_HOME
mkdir -p /tmp/jruby/gems /tmp/jruby/bin
export JRUBY_OPTS="-J-Djruby.gem.home=/tmp/jruby/gems -J-Djruby.bindir=/tmp/jruby/bin"

# check if we can install a new gem
jgem install rake
jgem list | grep -q "^rake ([0-9\.]\+)"

# invoke the new gem's binary
jruby -S rake --version
