From d51b4e34fbdbe1a845aa2251b1fa3304de809b32 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sun, 29 Sep 2019 19:13:35 +0200 Subject: [PATCH] Update to ruby/mspec@5dda9fb --- spec/mspec/lib/mspec/expectations/expectations.rb | 3 +++ spec/mspec/lib/mspec/helpers/warning.rb | 2 ++ spec/mspec/lib/mspec/matchers.rb | 1 + spec/mspec/lib/mspec/matchers/skip.rb | 5 +++++ spec/mspec/lib/mspec/runner/context.rb | 2 +- spec/mspec/lib/mspec/runner/mspec.rb | 2 ++ spec/mspec/spec/helpers/io_spec.rb | 4 ++-- 7 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 spec/mspec/lib/mspec/matchers/skip.rb diff --git a/spec/mspec/lib/mspec/expectations/expectations.rb b/spec/mspec/lib/mspec/expectations/expectations.rb index b42dfebb7f..8d01dc22ab 100644 --- a/spec/mspec/lib/mspec/expectations/expectations.rb +++ b/spec/mspec/lib/mspec/expectations/expectations.rb @@ -7,6 +7,9 @@ class SpecExpectationNotFoundError < StandardError end end +class SkippedSpecError < StandardError +end + class SpecExpectation def self.fail_with(expected, actual) expected_to_s = expected.to_s diff --git a/spec/mspec/lib/mspec/helpers/warning.rb b/spec/mspec/lib/mspec/helpers/warning.rb index f54e4abf4d..f94551c185 100644 --- a/spec/mspec/lib/mspec/helpers/warning.rb +++ b/spec/mspec/lib/mspec/helpers/warning.rb @@ -1,3 +1,5 @@ +require 'mspec/guards/version' + def suppress_warning verbose = $VERBOSE $VERBOSE = nil diff --git a/spec/mspec/lib/mspec/matchers.rb b/spec/mspec/lib/mspec/matchers.rb index f3e8e7bb73..356e4a9f32 100644 --- a/spec/mspec/lib/mspec/matchers.rb +++ b/spec/mspec/lib/mspec/matchers.rb @@ -34,3 +34,4 @@ require 'mspec/matchers/output_to_fd' require 'mspec/matchers/respond_to' require 'mspec/matchers/signed_zero' require 'mspec/matchers/block_caller' +require 'mspec/matchers/skip' diff --git a/spec/mspec/lib/mspec/matchers/skip.rb b/spec/mspec/lib/mspec/matchers/skip.rb new file mode 100644 index 0000000000..7c175d358d --- /dev/null +++ b/spec/mspec/lib/mspec/matchers/skip.rb @@ -0,0 +1,5 @@ +module MSpecMatchers + private def skip(reason = 'no reason') + raise SkippedSpecError, reason + end +end diff --git a/spec/mspec/lib/mspec/runner/context.rb b/spec/mspec/lib/mspec/runner/context.rb index 30d8a4ad1b..d72b947e0c 100644 --- a/spec/mspec/lib/mspec/runner/context.rb +++ b/spec/mspec/lib/mspec/runner/context.rb @@ -214,7 +214,7 @@ class ContextState if example passed = protect nil, example MSpec.actions :example, state, example - protect nil, @expectation_missing unless MSpec.expectation? or !passed + protect nil, @expectation_missing if !MSpec.expectation? and passed end end protect "after :each", post(:each) diff --git a/spec/mspec/lib/mspec/runner/mspec.rb b/spec/mspec/lib/mspec/runner/mspec.rb index cfc11840ac..75a242bef0 100644 --- a/spec/mspec/lib/mspec/runner/mspec.rb +++ b/spec/mspec/lib/mspec/runner/mspec.rb @@ -105,6 +105,8 @@ module MSpec return true rescue SystemExit => e raise e + rescue SkippedSpecError => e + return false rescue Exception => exc register_exit 1 actions :exception, ExceptionState.new(current && current.state, location, exc) diff --git a/spec/mspec/spec/helpers/io_spec.rb b/spec/mspec/spec/helpers/io_spec.rb index 86e42097f8..19f8384912 100644 --- a/spec/mspec/spec/helpers/io_spec.rb +++ b/spec/mspec/spec/helpers/io_spec.rb @@ -99,9 +99,9 @@ describe Object, "#new_io" do rm_r @name end - it "returns an IO instance" do + it "returns a File instance" do @io = new_io @name - @io.should be_an_instance_of(IO) + @io.should be_an_instance_of(File) end it "opens the IO for reading if passed 'r'" do