diff --git a/share/ruby-install/ruby/dependencies.sh b/share/ruby-install/ruby/dependencies.sh index 2f295ff6..dec30b32 100644 --- a/share/ruby-install/ruby/dependencies.sh +++ b/share/ruby-install/ruby/dependencies.sh @@ -9,7 +9,6 @@ case "$package_manager" in zlib1g-dev libyaml-dev libssl-dev - libgdbm-dev libreadline-dev libncurses-dev libffi-dev @@ -24,7 +23,6 @@ case "$package_manager" in zlib-devel libyaml-devel openssl-devel - gdbm-devel readline-devel ncurses-devel libffi-devel @@ -41,7 +39,6 @@ case "$package_manager" in openssl readline libyaml - gdbm libffi ) ;; @@ -54,7 +51,6 @@ case "$package_manager" in zlib-devel libyaml-devel libopenssl-devel - gdbm-devel readline-devel ncurses-devel libffi-devel @@ -67,7 +63,6 @@ case "$package_manager" in bison readline libyaml - gdbm libffi ) ;; @@ -76,7 +71,6 @@ case "$package_manager" in openssl readline libyaml - gdbm libffi ) ;; @@ -86,7 +80,6 @@ case "$package_manager" in openssl-devel zlib-devel libyaml-devel - gdbm-devel readline-devel ncurses-devel libffi-devel @@ -94,6 +87,14 @@ case "$package_manager" in ;; esac +if [[ "$ruby_version" < "3.1.0" ]]; then + case "$package_manager" in + apt) ruby_dependencies+=(libgdbm-dev) ;; + dnf|yum|zypper|xbps) ruby_dependencies+=(gdbm-devel) ;; + *) ruby_dependencies+=(gdbm) ;; + esac +fi + case "$package_manager" in brew|port) case "$ruby_version" in diff --git a/test/functions-tests/load_dependencies_test.sh b/test/functions-tests/load_dependencies_test.sh index 8ddb729b..397c0549 100755 --- a/test/functions-tests/load_dependencies_test.sh +++ b/test/functions-tests/load_dependencies_test.sh @@ -6,7 +6,7 @@ function setUp() { ruby="ruby" - ruby_version="3.0.0" + ruby_version="3.3.0" package_manager="dnf" } @@ -15,7 +15,8 @@ function test_load_dependencies() load_dependencies assertEquals "did not correctly set \$ruby_dependencies from \$ruby/dependencies.sh for \$package_manager" \ - "${ruby_dependencies[*]}" "xz gcc automake bison zlib-devel libyaml-devel openssl-devel gdbm-devel readline-devel ncurses-devel libffi-devel" + "xz gcc automake bison zlib-devel libyaml-devel openssl-devel readline-devel ncurses-devel libffi-devel" \ + "${ruby_dependencies[*]}" } function tearDown() diff --git a/test/ruby-tests/dependencies_tests.sh b/test/ruby-tests/dependencies_tests.sh index d7daff80..6ae96b53 100755 --- a/test/ruby-tests/dependencies_tests.sh +++ b/test/ruby-tests/dependencies_tests.sh @@ -20,7 +20,7 @@ function test_when_package_manager_is_apt() "$openssl_version" assertEquals "did not correctly set \$ruby_dependencies" \ - "xz-utils build-essential bison zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses-dev libffi-dev" \ + "xz-utils build-essential bison zlib1g-dev libyaml-dev libssl-dev libreadline-dev libncurses-dev libffi-dev" \ "${ruby_dependencies[*]}" package_manager="$original_package_manager" @@ -37,7 +37,7 @@ function test_when_package_manager_is_dnf() "$openssl_version" assertEquals "did not correctly set \$ruby_dependencies" \ - "xz gcc automake bison zlib-devel libyaml-devel openssl-devel gdbm-devel readline-devel ncurses-devel libffi-devel" \ + "xz gcc automake bison zlib-devel libyaml-devel openssl-devel readline-devel ncurses-devel libffi-devel" \ "${ruby_dependencies[*]}" package_manager="$original_package_manager" @@ -54,7 +54,7 @@ function test_when_package_manager_is_yum() "$openssl_version" assertEquals "did not correctly set \$ruby_dependencies" \ - "xz gcc automake bison zlib-devel libyaml-devel openssl-devel gdbm-devel readline-devel ncurses-devel libffi-devel" \ + "xz gcc automake bison zlib-devel libyaml-devel openssl-devel readline-devel ncurses-devel libffi-devel" \ "${ruby_dependencies[*]}" package_manager="$original_package_manager" @@ -71,7 +71,7 @@ function test_when_package_manager_is_pacman() "$openssl_version" assertEquals "did not correctly set \$ruby_dependencies" \ - "xz gcc make bison zlib ncurses openssl readline libyaml gdbm libffi" \ + "xz gcc make bison zlib ncurses openssl readline libyaml libffi" \ "${ruby_dependencies[*]}" package_manager="$original_package_manager" @@ -88,7 +88,7 @@ function test_when_package_manager_is_zypper() "$openssl_version" assertEquals "did not correctly set \$ruby_dependencies" \ - "xz gcc make automake zlib-devel libyaml-devel libopenssl-devel gdbm-devel readline-devel ncurses-devel libffi-devel" \ + "xz gcc make automake zlib-devel libyaml-devel libopenssl-devel readline-devel ncurses-devel libffi-devel" \ "${ruby_dependencies[*]}" package_manager="$original_package_manager" @@ -105,7 +105,7 @@ function test_when_package_manager_is_pkg() "$openssl_version" assertEquals "did not correctly set \$ruby_dependencies" \ - "openssl readline libyaml gdbm libffi" \ + "openssl readline libyaml libffi" \ "${ruby_dependencies[*]}" package_manager="$original_package_manager" @@ -122,12 +122,96 @@ function test_when_package_manager_is_xbps() "$openssl_version" assertEquals "did not correctly set \$ruby_dependencies" \ - "base-devel openssl-devel zlib-devel libyaml-devel gdbm-devel readline-devel ncurses-devel libffi-devel" \ + "base-devel openssl-devel zlib-devel libyaml-devel readline-devel ncurses-devel libffi-devel" \ "${ruby_dependencies[*]}" package_manager="$original_package_manager" } +function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_apt() +{ + local original_package_manager="$package_manager" + package_manager="apt" + ruby_version="3.0.7" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertTrue "did not add libgdbm-dev to \$ruby_dependencies" \ + '[[ " ${ruby_dependencies[*]} " == *" libgdbm-dev "* ]]' + + package_manager="$original_package_manager" +} + +function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_dnf() +{ + local original_package_manager="$package_manager" + package_manager="dnf" + ruby_version="3.0.7" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertTrue "did not add gdbm-devel to \$ruby_dependencies" \ + '[[ " ${ruby_dependencies[*]} " == *" gdbm-devel "* ]]' + + package_manager="$original_package_manager" +} + +function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_yum() +{ + local original_package_manager="$package_manager" + package_manager="yum" + ruby_version="3.0.7" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertTrue "did not add gdbm-devel to \$ruby_dependencies" \ + '[[ " ${ruby_dependencies[*]} " == *" gdbm-devel "* ]]' + + package_manager="$original_package_manager" +} + +function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_zypper() +{ + local original_package_manager="$package_manager" + package_manager="zypper" + ruby_version="3.0.7" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertTrue "did not add gdbm-devel to \$ruby_dependencies" \ + '[[ " ${ruby_dependencies[*]} " == *" gdbm-devel "* ]]' + + package_manager="$original_package_manager" +} + +function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_xbps() +{ + local original_package_manager="$package_manager" + package_manager="xbps" + ruby_version="3.0.7" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertTrue "did not add gdbm-devel to \$ruby_dependencies" \ + '[[ " ${ruby_dependencies[*]} " == *" gdbm-devel "* ]]' + + package_manager="$original_package_manager" +} + +function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_other() +{ + local original_package_manager="$package_manager" + package_manager="brew" + ruby_version="3.0.7" + + source "$ruby_install_dir/$ruby/dependencies.sh" + + assertTrue "did not add gdbm-devel to \$ruby_dependencies" \ + '[[ " ${ruby_dependencies[*]} " == *" gdbm "* ]]' + + package_manager="$original_package_manager" +} + function test_when_package_manager_is_brew_and_ruby_version_is_less_than_3_1_0() { local original_package_manager="$package_manager"