diff options
Diffstat (limited to 'spec/mspec/spec/runner/formatters/unit_spec.rb')
-rw-r--r-- | spec/mspec/spec/runner/formatters/unit_spec.rb | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/spec/mspec/spec/runner/formatters/unit_spec.rb b/spec/mspec/spec/runner/formatters/unit_spec.rb index 18167a32b8..d349e6871d 100644 --- a/spec/mspec/spec/runner/formatters/unit_spec.rb +++ b/spec/mspec/spec/runner/formatters/unit_spec.rb @@ -3,17 +3,17 @@ require 'mspec/runner/formatters/unit' require 'mspec/runner/example' require 'mspec/utils/script' -describe UnitdiffFormatter, "#finish" do +RSpec.describe UnitdiffFormatter, "#finish" do before :each do @tally = double("tally").as_null_object - TallyAction.stub(:new).and_return(@tally) + allow(TallyAction).to receive(:new).and_return(@tally) @timer = double("timer").as_null_object - TimerAction.stub(:new).and_return(@timer) + allow(TimerAction).to receive(:new).and_return(@timer) $stdout = @out = IOStub.new context = ContextState.new "describe" @state = ExampleState.new(context, "it") - MSpec.stub(:register) + allow(MSpec).to receive(:register) @formatter = UnitdiffFormatter.new @formatter.register end @@ -27,39 +27,38 @@ describe UnitdiffFormatter, "#finish" do @formatter.exception exc @formatter.after @state @formatter.finish - @out.should =~ /^1\)\ndescribe it ERROR$/ + expect(@out).to match(/^1\)\ndescribe it ERROR$/) end it "prints a backtrace for an exception" do exc = ExceptionState.new @state, nil, Exception.new("broken") - exc.stub(:backtrace).and_return("path/to/some/file.rb:35:in method") + allow(exc).to receive(:backtrace).and_return("path/to/some/file.rb:35:in method") @formatter.exception exc @formatter.finish - @out.should =~ %r[path/to/some/file.rb:35:in method$] + expect(@out).to match(%r[path/to/some/file.rb:35:in method$]) end it "prints a summary of elapsed time" do - @timer.should_receive(:format).and_return("Finished in 2.0 seconds") + expect(@timer).to receive(:format).and_return("Finished in 2.0 seconds") @formatter.finish - @out.should =~ /^Finished in 2.0 seconds$/ + expect(@out).to match(/^Finished in 2.0 seconds$/) end it "prints a tally of counts" do - @tally.should_receive(:format).and_return("1 example, 0 failures") + expect(@tally).to receive(:format).and_return("1 example, 0 failures") @formatter.finish - @out.should =~ /^1 example, 0 failures$/ + expect(@out).to match(/^1 example, 0 failures$/) end it "prints errors, backtraces, elapsed time, and tallies" do exc = ExceptionState.new @state, nil, Exception.new("broken") - exc.stub(:backtrace).and_return("path/to/some/file.rb:35:in method") + allow(exc).to receive(:backtrace).and_return("path/to/some/file.rb:35:in method") @formatter.exception exc @formatter.after @state - @timer.should_receive(:format).and_return("Finished in 2.0 seconds") - @tally.should_receive(:format).and_return("1 example, 0 failures") + expect(@timer).to receive(:format).and_return("Finished in 2.0 seconds") + expect(@tally).to receive(:format).and_return("1 example, 0 failures") @formatter.finish - @out.should == -%[E + expect(@out).to eq(%[E Finished in 2.0 seconds @@ -69,6 +68,6 @@ Exception: broken: path/to/some/file.rb:35:in method 1 example, 0 failures -] +]) end end |