diff options
Diffstat (limited to 'spec/mspec/spec/helpers/ruby_exe_spec.rb')
-rw-r--r-- | spec/mspec/spec/helpers/ruby_exe_spec.rb | 59 |
1 files changed, 16 insertions, 43 deletions
diff --git a/spec/mspec/spec/helpers/ruby_exe_spec.rb b/spec/mspec/spec/helpers/ruby_exe_spec.rb index 474ad7b51a..8036043578 100644 --- a/spec/mspec/spec/helpers/ruby_exe_spec.rb +++ b/spec/mspec/spec/helpers/ruby_exe_spec.rb @@ -11,24 +11,13 @@ class RubyExeSpecs end describe "#ruby_exe_options" do - before :all do - @verbose = $VERBOSE - $VERBOSE = nil - - @ruby_engine = Object.const_get :RUBY_ENGINE + before :each do @ruby_exe_env = ENV['RUBY_EXE'] - @script = RubyExeSpecs.new end - after :all do - Object.const_set :RUBY_ENGINE, @ruby_engine + after :each do ENV['RUBY_EXE'] = @ruby_exe_env - $VERBOSE = @verbose - end - - before :each do - @script = RubyExeSpecs.new end it "returns ENV['RUBY_EXE'] when passed :env" do @@ -37,27 +26,27 @@ describe "#ruby_exe_options" do end it "returns 'bin/jruby' when passed :engine and RUBY_ENGINE is 'jruby'" do - Object.const_set :RUBY_ENGINE, 'jruby' + stub_const "RUBY_ENGINE", 'jruby' @script.ruby_exe_options(:engine).should == 'bin/jruby' end it "returns 'bin/rbx' when passed :engine, RUBY_ENGINE is 'rbx'" do - Object.const_set :RUBY_ENGINE, 'rbx' + stub_const "RUBY_ENGINE", 'rbx' @script.ruby_exe_options(:engine).should == 'bin/rbx' end it "returns 'ir' when passed :engine and RUBY_ENGINE is 'ironruby'" do - Object.const_set :RUBY_ENGINE, 'ironruby' + stub_const "RUBY_ENGINE", 'ironruby' @script.ruby_exe_options(:engine).should == 'ir' end it "returns 'maglev-ruby' when passed :engine and RUBY_ENGINE is 'maglev'" do - Object.const_set :RUBY_ENGINE, 'maglev' + stub_const "RUBY_ENGINE", 'maglev' @script.ruby_exe_options(:engine).should == 'maglev-ruby' end it "returns 'topaz' when passed :engine and RUBY_ENGINE is 'topaz'" do - Object.const_set :RUBY_ENGINE, 'topaz' + stub_const "RUBY_ENGINE", 'topaz' @script.ruby_exe_options(:engine).should == 'topaz' end @@ -75,21 +64,11 @@ describe "#ruby_exe_options" do end describe "#resolve_ruby_exe" do - before :all do - @verbose = $VERBOSE - $VERBOSE = nil - - @name = "ruby_spec_exe" - end - before :each do + @name = "ruby_spec_exe" @script = RubyExeSpecs.new end - after :all do - $VERBOSE = @verbose - end - it "returns the value returned by #ruby_exe_options if it exists and is executable" do @script.should_receive(:ruby_exe_options).and_return(@name) File.should_receive(:file?).with(@name).and_return(true) @@ -126,12 +105,8 @@ describe "#resolve_ruby_exe" do end describe Object, "#ruby_cmd" do - before :all do - @verbose = $VERBOSE - $VERBOSE = nil - - @ruby_exe = Object.const_get :RUBY_EXE - Object.const_set :RUBY_EXE, 'ruby_spec_exe -w -Q' + before :each do + stub_const 'RUBY_EXE', 'ruby_spec_exe -w -Q' @file = "some/ruby/file.rb" @code = %(some "real" 'ruby' code) @@ -139,11 +114,6 @@ describe Object, "#ruby_cmd" do @script = RubyExeSpecs.new end - after :all do - Object.const_set :RUBY_EXE, @ruby_exe - $VERBOSE = @verbose - end - it "returns a command that runs the given file if it is a file that exists" do File.should_receive(:exist?).with(@file).and_return(true) @script.ruby_cmd(@file).should == "ruby_spec_exe -w -Q some/ruby/file.rb" @@ -168,12 +138,15 @@ describe Object, "#ruby_cmd" do end describe Object, "#ruby_exe" do - before :all do + before :each do + stub_const 'RUBY_EXE', 'ruby_spec_exe -w -Q' + @script = RubyExeSpecs.new + @script.stub(:`) end - before :each do - @script.stub(:`) + it "returns an Array containing the interpreter executable and flags when given no arguments" do + @script.ruby_exe.should == ['ruby_spec_exe', '-w', '-Q'] end it "executes (using `) the result of calling #ruby_cmd with the given arguments" do |