lib/tspec.rb in tspec-0.2.0 vs lib/tspec.rb in tspec-0.3.0

- old
+ new

@@ -1,16 +1,7 @@ -module TSpec - class ReturnValueTypeError < StandardError - end +require 'tspec/type_error' - class NotFoundArgumentNameError < StandardError - end - - class ArgumentTypeError < StandardError - end -end - class Symbol def return(*types) self end @@ -101,10 +92,14 @@ value = tp.binding.local_variable_get(name) unless value_type_check(value, *type) @type_error_flag = true - raise ArgumentTypeError, "##{tp.method_id} '#{name}' variable should be #{type.inspect}, but actual '#{value.inspect}' - #{value.class}" + if type.instance_of?(Array) + raise ArgumentTypeError, "##{tp.method_id} '#{name}' variable should be #{type.map(&:inspect).join(' or ')}, but actual '#{value.inspect}' - #{value.class}" + else + raise ArgumentTypeError, "##{tp.method_id} '#{name}' variable should be #{type.inspect}, but actual '#{value.inspect}' - #{value.class}" + end end end end end when :return