diff options
Diffstat (limited to 'spec/mspec/spec/guards/platform_spec.rb')
-rw-r--r-- | spec/mspec/spec/guards/platform_spec.rb | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/spec/mspec/spec/guards/platform_spec.rb b/spec/mspec/spec/guards/platform_spec.rb index f0af12c1f8..749963d3db 100644 --- a/spec/mspec/spec/guards/platform_spec.rb +++ b/spec/mspec/spec/guards/platform_spec.rb @@ -20,6 +20,13 @@ describe Object, "#platform_is" do ScratchPad.recorded.should == :yield end + it "returns what #os? returns when no block is given" do + PlatformGuard.stub(:os?).and_return(true) + platform_is(:solarce).should == true + PlatformGuard.stub(:os?).and_return(false) + platform_is(:solarce).should == false + end + it "sets the name of the guard to :platform_is" do platform_is(:solarce) { } @guard.name.should == :platform_is @@ -53,6 +60,13 @@ describe Object, "#platform_is_not" do ScratchPad.recorded.should == :yield end + it "returns the opposite of what #os? returns when no block is given" do + PlatformGuard.stub(:os?).and_return(true) + platform_is_not(:solarce).should == false + PlatformGuard.stub(:os?).and_return(false) + platform_is_not(:solarce).should == true + end + it "sets the name of the guard to :platform_is_not" do platform_is_not(:solarce) { } @guard.name.should == :platform_is_not @@ -110,66 +124,49 @@ describe Object, "#platform_is_not :wordsize => SIZE_SPEC" do end describe PlatformGuard, ".implementation?" do - before :all do - @verbose = $VERBOSE - $VERBOSE = nil - end - - after :all do - $VERBOSE = @verbose - end - - before :each do - @ruby_engine = Object.const_get :RUBY_ENGINE - end - - after :each do - Object.const_set :RUBY_ENGINE, @ruby_engine - end - it "returns true if passed :ruby and RUBY_ENGINE == 'ruby'" do - Object.const_set :RUBY_ENGINE, 'ruby' + stub_const 'RUBY_ENGINE', 'ruby' PlatformGuard.implementation?(:ruby).should == true end it "returns true if passed :rubinius and RUBY_ENGINE == 'rbx'" do - Object.const_set :RUBY_ENGINE, 'rbx' + stub_const 'RUBY_ENGINE', 'rbx' PlatformGuard.implementation?(:rubinius).should == true end it "returns true if passed :jruby and RUBY_ENGINE == 'jruby'" do - Object.const_set :RUBY_ENGINE, 'jruby' + stub_const 'RUBY_ENGINE', 'jruby' PlatformGuard.implementation?(:jruby).should == true end it "returns true if passed :ironruby and RUBY_ENGINE == 'ironruby'" do - Object.const_set :RUBY_ENGINE, 'ironruby' + stub_const 'RUBY_ENGINE', 'ironruby' PlatformGuard.implementation?(:ironruby).should == true end it "returns true if passed :maglev and RUBY_ENGINE == 'maglev'" do - Object.const_set :RUBY_ENGINE, 'maglev' + stub_const 'RUBY_ENGINE', 'maglev' PlatformGuard.implementation?(:maglev).should == true end it "returns true if passed :topaz and RUBY_ENGINE == 'topaz'" do - Object.const_set :RUBY_ENGINE, 'topaz' + stub_const 'RUBY_ENGINE', 'topaz' PlatformGuard.implementation?(:topaz).should == true end it "returns true if passed :ruby and RUBY_ENGINE matches /^ruby/" do - Object.const_set :RUBY_ENGINE, 'ruby' + stub_const 'RUBY_ENGINE', 'ruby' PlatformGuard.implementation?(:ruby).should == true - Object.const_set :RUBY_ENGINE, 'ruby1.8' + stub_const 'RUBY_ENGINE', 'ruby1.8' PlatformGuard.implementation?(:ruby).should == true - Object.const_set :RUBY_ENGINE, 'ruby1.9' + stub_const 'RUBY_ENGINE', 'ruby1.9' PlatformGuard.implementation?(:ruby).should == true end it "raises an error when passed an unrecognized name" do - Object.const_set :RUBY_ENGINE, 'ruby' + stub_const 'RUBY_ENGINE', 'ruby' lambda { PlatformGuard.implementation?(:python) }.should raise_error(/unknown implementation/) |