Sha256: 70335d082a783d9cef75559270a8c3a623fd411eda1482c6f085b86c3cdbab4b

Contents?: true

Size: 722 Bytes

Versions: 3

Compression:

Stored size: 722 Bytes

Contents

class GuardException
  def initialize(example, exception)
    @message = example && example.description || "<no description>"
    @exception = exception
    @method = exception.backtrace.first
  end

  def finish(*args)
    print "Skipped '#{@message}'\n\t#{@exception}\n\tin #{@method}).\n\n"
  end
end

module MSpec
  class << self
    alias mspec_protect protect

    def protect(location, &block)
      wrapped_block = proc do
        begin
          instance_eval(&block)
        rescue *MSpec.retrieve(:guarding_exceptions)
          MSpec.expectation
          MSpec.register :finish, GuardException.new(MSpec.current.state, $!)
        end
      end
      mspec_protect(location, &wrapped_block)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubymirrors-0.0.3 spec/spec_helper/mspec_patch.rb
rubymirrors-0.0.2 spec/spec_helper/mspec_patch.rb
rubymirrors-0.0.1 spec/spec_helper/mspec_patch.rb