class Spec::Matchers::ThrowSymbol

:nodoc:

def description

def description
  "throw #{expected}"
end

def expected

def expected
  @expected.nil? ? "a Symbol" : @expected.inspect
end

def failure_message

def failure_message
  if @actual
    "expected #{expected}, got #{@actual.inspect}"
  else
    "expected #{expected} but nothing was thrown"
  end
end

def initialize(expected=nil)

:nodoc:
def initialize(expected=nil)
  @expected = expected
  @actual = nil
end

def matches?(given_proc)

def matches?(given_proc)
  begin
    given_proc.call
  rescue NameError => e
    raise e unless e.message =~ /uncaught throw/
    @actual = e.name.to_sym
  ensure
    if @expected.nil?
      return @actual.nil? ? false : true
    else
      return @actual == @expected
    end
  end
end

def negative_failure_message

def negative_failure_message
  if @expected
    "expected #{expected} not to be thrown"
  else
    "expected no Symbol, got :#{@actual}"
  end
end