diff options
Diffstat (limited to 'spec/ruby/library/rbconfig')
| -rw-r--r-- | spec/ruby/library/rbconfig/rbconfig_spec.rb | 70 | ||||
| -rw-r--r-- | spec/ruby/library/rbconfig/sizeof/limits_spec.rb | 6 | ||||
| -rw-r--r-- | spec/ruby/library/rbconfig/sizeof/sizeof_spec.rb | 6 | ||||
| -rw-r--r-- | spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb | 18 | ||||
| -rw-r--r-- | spec/ruby/library/rbconfig/unicode_version_spec.rb | 18 |
5 files changed, 84 insertions, 34 deletions
diff --git a/spec/ruby/library/rbconfig/rbconfig_spec.rb b/spec/ruby/library/rbconfig/rbconfig_spec.rb index b90cc90970..4195128a05 100644 --- a/spec/ruby/library/rbconfig/rbconfig_spec.rb +++ b/spec/ruby/library/rbconfig/rbconfig_spec.rb @@ -4,11 +4,18 @@ require 'rbconfig' describe 'RbConfig::CONFIG' do it 'values are all strings' do RbConfig::CONFIG.each do |k, v| - k.should be_kind_of String - v.should be_kind_of String + k.should.is_a? String + v.should.is_a? String end end + it 'has MAJOR, MINOR, TEENY, and PATCHLEVEL matching RUBY_VERSION and RUBY_PATCHLEVEL' do + major, minor, teeny = RUBY_VERSION.split('.') + RbConfig::CONFIG.values_at("MAJOR", "MINOR", "TEENY", "PATCHLEVEL").should == [ + major, minor, teeny, RUBY_PATCHLEVEL.to_s + ] + end + # These directories have no meanings before the installation. guard -> { RbConfig::TOPDIR } do it "['rubylibdir'] returns the directory containing Ruby standard libraries" do @@ -25,7 +32,7 @@ describe 'RbConfig::CONFIG' do it "['sitelibdir'] is set and is part of $LOAD_PATH" do sitelibdir = RbConfig::CONFIG['sitelibdir'] - sitelibdir.should be_kind_of String + sitelibdir.should.is_a? String $LOAD_PATH.map{|path| File.realpath(path) rescue path }.should.include? sitelibdir end end @@ -73,7 +80,7 @@ describe 'RbConfig::CONFIG' do ar = RbConfig::CONFIG.fetch('AR') out = `#{ar} --version` $?.should.success? - out.should_not be_empty + out.should_not.empty? end it "['STRIP'] exists and can be executed" do @@ -88,6 +95,30 @@ describe 'RbConfig::CONFIG' do end end end + + guard -> { %w[aarch64 arm64].include? RbConfig::CONFIG['host_cpu'] } do + it "['host_cpu'] returns CPU architecture properly for AArch64" do + platform_is :darwin do + RbConfig::CONFIG['host_cpu'].should == 'arm64' + end + + platform_is_not :darwin do + RbConfig::CONFIG['host_cpu'].should == 'aarch64' + end + end + end + + guard -> { platform_is(:linux) || platform_is(:darwin) } do + it "['host_os'] returns a proper OS name or platform" do + platform_is :darwin do + RbConfig::CONFIG['host_os'].should.match?(/darwin/) + end + + platform_is :linux do + RbConfig::CONFIG['host_os'].should.match?(/linux/) + end + end + end end describe "RbConfig::TOPDIR" do @@ -99,3 +130,34 @@ describe "RbConfig::TOPDIR" do end end end + +describe "RUBY_PLATFORM" do + it "RUBY_PLATFORM contains a proper CPU architecture" do + RUBY_PLATFORM.should.include? RbConfig::CONFIG['host_cpu'] + end + + guard -> { platform_is(:linux) || platform_is(:darwin) } do + it "RUBY_PLATFORM contains OS name" do + # don't use RbConfig::CONFIG['host_os'] as far as it could be slightly different, e.g. linux-gnu + platform_is(:linux) do + RUBY_PLATFORM.should.include? 'linux' + end + + platform_is(:darwin) do + RUBY_PLATFORM.should.include? 'darwin' + end + end + end +end + +describe "RUBY_DESCRIPTION" do + guard_not -> { RUBY_ENGINE == "ruby" && !RbConfig::TOPDIR } do + it "contains version" do + RUBY_DESCRIPTION.should.include? RUBY_VERSION + end + + it "contains RUBY_PLATFORM" do + RUBY_DESCRIPTION.should.include? RUBY_PLATFORM + end + end +end diff --git a/spec/ruby/library/rbconfig/sizeof/limits_spec.rb b/spec/ruby/library/rbconfig/sizeof/limits_spec.rb index 776099da27..08b1185965 100644 --- a/spec/ruby/library/rbconfig/sizeof/limits_spec.rb +++ b/spec/ruby/library/rbconfig/sizeof/limits_spec.rb @@ -3,13 +3,13 @@ require 'rbconfig/sizeof' describe "RbConfig::LIMITS" do it "is a Hash" do - RbConfig::LIMITS.should be_kind_of(Hash) + RbConfig::LIMITS.should.is_a?(Hash) end it "has string keys and numeric values" do RbConfig::LIMITS.each do |key, value| - key.should be_kind_of String - value.should be_kind_of Numeric + key.should.is_a? String + value.should.is_a? Numeric end end diff --git a/spec/ruby/library/rbconfig/sizeof/sizeof_spec.rb b/spec/ruby/library/rbconfig/sizeof/sizeof_spec.rb index f2582dc4fd..b74dae5166 100644 --- a/spec/ruby/library/rbconfig/sizeof/sizeof_spec.rb +++ b/spec/ruby/library/rbconfig/sizeof/sizeof_spec.rb @@ -3,13 +3,13 @@ require 'rbconfig/sizeof' describe "RbConfig::SIZEOF" do it "is a Hash" do - RbConfig::SIZEOF.should be_kind_of(Hash) + RbConfig::SIZEOF.should.is_a?(Hash) end it "has string keys and integer values" do RbConfig::SIZEOF.each do |key, value| - key.should be_kind_of String - value.should be_kind_of Integer + key.should.is_a? String + value.should.is_a? Integer end end diff --git a/spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb b/spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb index a4a24c535d..521a750bf7 100644 --- a/spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb +++ b/spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb @@ -2,22 +2,16 @@ require_relative '../../spec_helper' require 'rbconfig' describe "RbConfig::CONFIG['UNICODE_EMOJI_VERSION']" do - ruby_version_is ""..."3.1" do - it "is 12.1" do - RbConfig::CONFIG['UNICODE_EMOJI_VERSION'].should == "12.1" - end - end - - ruby_version_is "3.1"..."3.2" do - it "is 13.1" do - RbConfig::CONFIG['UNICODE_EMOJI_VERSION'].should == "13.1" + ruby_version_is ""..."3.4" do + it "is 15.0" do + RbConfig::CONFIG['UNICODE_EMOJI_VERSION'].should == "15.0" end end # Caution: ruby_version_is means is_or_later - ruby_version_is "3.2" do - it "is 14.0" do - RbConfig::CONFIG['UNICODE_EMOJI_VERSION'].should == "14.0" + ruby_version_is "4.0" do + it "is 17.0" do + RbConfig::CONFIG['UNICODE_EMOJI_VERSION'].should == "17.0" end end end diff --git a/spec/ruby/library/rbconfig/unicode_version_spec.rb b/spec/ruby/library/rbconfig/unicode_version_spec.rb index d0ff856764..5cdde74f79 100644 --- a/spec/ruby/library/rbconfig/unicode_version_spec.rb +++ b/spec/ruby/library/rbconfig/unicode_version_spec.rb @@ -2,22 +2,16 @@ require_relative '../../spec_helper' require 'rbconfig' describe "RbConfig::CONFIG['UNICODE_VERSION']" do - ruby_version_is ""..."3.1" do - it "is 12.1.0" do - RbConfig::CONFIG['UNICODE_VERSION'].should == "12.1.0" - end - end - - ruby_version_is "3.1"..."3.2" do - it "is 13.0.0" do - RbConfig::CONFIG['UNICODE_VERSION'].should == "13.0.0" + ruby_version_is ""..."3.4" do + it "is 15.0.0" do + RbConfig::CONFIG['UNICODE_VERSION'].should == "15.0.0" end end # Caution: ruby_version_is means is_or_later - ruby_version_is "3.2" do - it "is 14.0.0" do - RbConfig::CONFIG['UNICODE_VERSION'].should == "14.0.0" + ruby_version_is "4.0" do + it "is 17.0.0" do + RbConfig::CONFIG['UNICODE_VERSION'].should == "17.0.0" end end end |
