From d55cd34ba8680310fb07c2f5c1c6a27b4902865d Mon Sep 17 00:00:00 2001 From: eregon Date: Thu, 29 Jun 2017 14:35:09 +0000 Subject: Update to ruby/mspec@021a119 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/mspec/spec/commands/mspec_spec.rb | 6 +-- spec/mspec/spec/expectations/should.rb | 1 + spec/mspec/spec/fixtures/object_methods_spec.rb | 8 +++ spec/mspec/spec/helpers/ruby_exe_spec.rb | 59 ++++++---------------- spec/mspec/spec/integration/object_methods_spec.rb | 18 +++++++ spec/mspec/spec/matchers/output_to_fd_spec.rb | 24 +++++---- spec/mspec/spec/mocks/mock_spec.rb | 6 +-- spec/mspec/spec/runner/shared_spec.rb | 2 + 8 files changed, 63 insertions(+), 61 deletions(-) create mode 100644 spec/mspec/spec/fixtures/object_methods_spec.rb create mode 100644 spec/mspec/spec/integration/object_methods_spec.rb (limited to 'spec/mspec/spec') diff --git a/spec/mspec/spec/commands/mspec_spec.rb b/spec/mspec/spec/commands/mspec_spec.rb index 5d2134a054..b01af6b41b 100644 --- a/spec/mspec/spec/commands/mspec_spec.rb +++ b/spec/mspec/spec/commands/mspec_spec.rb @@ -60,13 +60,13 @@ describe MSpecMain, "#run" do end it "uses exec to invoke the runner script" do - @script.should_receive(:exec).with("ruby", "#{MSPEC_HOME}/bin/mspec-run") + @script.should_receive(:exec).with("ruby", "#{MSPEC_HOME}/bin/mspec-run", close_others: false) @script.options [] @script.run end it "shows the command line on stderr" do - @script.should_receive(:exec).with("ruby", "#{MSPEC_HOME}/bin/mspec-run") + @script.should_receive(:exec).with("ruby", "#{MSPEC_HOME}/bin/mspec-run", close_others: false) @script.options [] @script.run $stderr.to_s.should == "$ ruby #{Dir.pwd}/bin/mspec-run\n" @@ -74,7 +74,7 @@ describe MSpecMain, "#run" do it "adds config[:launch] to the exec options" do @script.should_receive(:exec).with("ruby", - "-Xlaunch.option", "#{MSPEC_HOME}/bin/mspec-run") + "-Xlaunch.option", "#{MSPEC_HOME}/bin/mspec-run", close_others: false) @config[:launch] << "-Xlaunch.option" @script.options [] @script.run diff --git a/spec/mspec/spec/expectations/should.rb b/spec/mspec/spec/expectations/should.rb index 8404ff044e..24b1cf2bf8 100644 --- a/spec/mspec/spec/expectations/should.rb +++ b/spec/mspec/spec/expectations/should.rb @@ -33,6 +33,7 @@ MSpec.register :finish, monitor at_exit { MSpec.actions :finish } MSpec.actions :start +MSpec.setup_env # Specs describe "MSpec expectation method #should" do diff --git a/spec/mspec/spec/fixtures/object_methods_spec.rb b/spec/mspec/spec/fixtures/object_methods_spec.rb new file mode 100644 index 0000000000..9b7c1523e5 --- /dev/null +++ b/spec/mspec/spec/fixtures/object_methods_spec.rb @@ -0,0 +1,8 @@ +unless defined?(RSpec) + describe "Object" do + it ".public_instance_methods(false) is empty" do + Object.public_instance_methods(false).sort.should == + [:should, :should_not, :should_not_receive, :should_receive, :stub!] + end + end +end 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 diff --git a/spec/mspec/spec/integration/object_methods_spec.rb b/spec/mspec/spec/integration/object_methods_spec.rb new file mode 100644 index 0000000000..3be704beb6 --- /dev/null +++ b/spec/mspec/spec/integration/object_methods_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +expected_output = < true MSpec.stub(:retrieve_shared).and_return(@shared) @@ -51,6 +52,7 @@ describe Object, "#it_behaves_like" do @state2 = ContextState.new "Second top level" @state2.instance_variable_set :@parsed, true + @state2.singleton_class.send(:public, :it_behaves_like) end it "ensures the shared spec state is distinct" do -- cgit v1.2.3