bin/test
#!/bin/bash
set -e
RUBY_V=$(ruby -v)
function reset_gemfile_and_test {
rm Gemfile.lock
eval "$1 bundle update"
eval "$1 bundle exec rake test"
}
function test_with_activemodel {
reset_gemfile_and_test "ACTIVEMODEL_VERSION=$1"
}
function run_tests_by_modules {
rm Gemfile.lock
bundle update
eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/{basic/*_test,basic_test}.rb'"
eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/enum_test.rb'"
eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/presence_test.rb'"
eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/dig_test.rb'"
eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/try_test.rb'"
eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/maybe_test.rb'"
eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/immutable_attributes_test.rb'"
eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/function_test.rb'"
eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/action_test.rb'"
eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/{functional/*_test,functional_test}.rb'"
eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/either/*_test.rb'"
eval "KIND_BASIC=t bundle exec rake test TEST='test/kind/result/*_test.rb'"
eval "KIND_STRICT=t bundle exec rake test TEST='test/kind/strict_disabled_test.rb'"
}
RUBY_2_12345="ruby 2.[12345]."
RUBY_2_2345="ruby 2.[2345]."
RUBY_2_1234="ruby 2.[1234]."
RUBY_2_567="ruby 2.[567]."
RUBY_2_12="ruby 2.[12]."
RUBY_2_7="ruby 2.7."
RUBY_3_X="ruby 3."
if [[ $RUBY_V =~ $RUBY_2_12345 ]]; then
if [[ $RUBY_V =~ $RUBY_2_12 ]]; then
test_with_activemodel "3.2"
fi
if [[ $RUBY_V =~ $RUBY_2_2345 ]]; then
test_with_activemodel "4.0"
test_with_activemodel "4.1"
test_with_activemodel "4.2"
test_with_activemodel "5.0"
test_with_activemodel "5.1"
test_with_activemodel "5.2"
fi
if [[ $RUBY_V =~ $RUBY_2_1234 ]]; then
run_tests_by_modules
reset_gemfile_and_test
fi
fi
if [[ $RUBY_V =~ $RUBY_2_567 ]] || [[ $RUBY_V =~ $RUBY_3_X ]]; then
gem install bundler -v ">= 2" --no-doc
test_with_activemodel "6.0"
test_with_activemodel "6.1"
if [[ $RUBY_V =~ $RUBY_2_7 ]] || [[ $RUBY_V =~ $RUBY_3_X ]]; then
test_with_activemodel "7.0"
fi
run_tests_by_modules
reset_gemfile_and_test
fi