From 820f99791eb813bd72ddce2f5b5c4173d3b69b7b Mon Sep 17 00:00:00 2001 From: eregon Date: Thu, 7 Feb 2019 16:35:03 +0000 Subject: Update to ruby/mspec@231e2ce git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/mspec/spec/guards/platform_spec.rb | 38 +++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'spec/mspec/spec/guards/platform_spec.rb') diff --git a/spec/mspec/spec/guards/platform_spec.rb b/spec/mspec/spec/guards/platform_spec.rb index 749963d3db..ad1e3695ca 100644 --- a/spec/mspec/spec/guards/platform_spec.rb +++ b/spec/mspec/spec/guards/platform_spec.rb @@ -197,7 +197,7 @@ end describe PlatformGuard, ".os?" do before :each do - stub_const 'PlatformGuard::HOST_OS', 'solarce' + stub_const 'PlatformGuard::PLATFORM', 'solarce' end it "returns false when arg does not match the platform" do @@ -217,26 +217,36 @@ describe PlatformGuard, ".os?" do end it "returns true when arg is :windows and the platform contains 'mswin'" do - stub_const 'PlatformGuard::HOST_OS', 'mswin32' + stub_const 'PlatformGuard::PLATFORM', 'mswin32' PlatformGuard.os?(:windows).should == true end it "returns true when arg is :windows and the platform contains 'mingw'" do - stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32' + stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32' PlatformGuard.os?(:windows).should == true end it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do - stub_const 'PlatformGuard::HOST_OS', 'i386-mswin32' + stub_const 'PlatformGuard::PLATFORM', 'i386-mswin32' PlatformGuard.os?(:linux).should == false end it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do - stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32' + stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32' PlatformGuard.os?(:linux).should == false end end +describe PlatformGuard, ".os?" do + it "returns true if called with the current OS or architecture" do + os = RbConfig::CONFIG["host_os"].sub("-gnu", "") + arch = RbConfig::CONFIG["host_arch"] + PlatformGuard.os?(os).should == true + PlatformGuard.os?(arch).should == true + PlatformGuard.os?("#{arch}-#{os}").should == true + end +end + describe PlatformGuard, ".os? on JRuby" do before :all do @verbose = $VERBOSE @@ -263,19 +273,19 @@ describe PlatformGuard, ".os? on JRuby" do end it "returns true when arg is :windows and RUBY_PLATFORM contains 'java' and os?(:windows) is true" do - stub_const 'PlatformGuard::HOST_OS', 'mswin32' + stub_const 'PlatformGuard::PLATFORM', 'mswin32' PlatformGuard.os?(:windows).should == true end it "returns true when RUBY_PLATFORM contains 'java' and os?(argument) is true" do - stub_const 'PlatformGuard::HOST_OS', 'amiga' + stub_const 'PlatformGuard::PLATFORM', 'amiga' PlatformGuard.os?(:amiga).should == true end end describe PlatformGuard, ".os?" do before :each do - stub_const 'PlatformGuard::HOST_OS', 'unreal' + stub_const 'PlatformGuard::PLATFORM', 'unreal' end it "returns true if argument matches RbConfig::CONFIG['host_os']" do @@ -295,34 +305,34 @@ describe PlatformGuard, ".os?" do end it "returns true when arg is :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do - stub_const 'PlatformGuard::HOST_OS', 'i386-mswin32' + stub_const 'PlatformGuard::PLATFORM', 'i386-mswin32' PlatformGuard.os?(:windows).should == true end it "returns true when arg is :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do - stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32' + stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32' PlatformGuard.os?(:windows).should == true end it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mswin'" do - stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32' + stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32' PlatformGuard.os?(:linux).should == false end it "returns false when arg is not :windows and RbConfig::CONFIG['host_os'] contains 'mingw'" do - stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32' + stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32' PlatformGuard.os?(:linux).should == false end end describe PlatformGuard, ".windows?" do it "returns true on windows" do - stub_const 'PlatformGuard::HOST_OS', 'i386-mingw32' + stub_const 'PlatformGuard::PLATFORM', 'i386-mingw32' PlatformGuard.windows?.should == true end it "returns false on non-windows" do - stub_const 'PlatformGuard::HOST_OS', 'i586-linux' + stub_const 'PlatformGuard::PLATFORM', 'i586-linux' PlatformGuard.windows?.should == false end end -- cgit v1.2.3