test/unit/schemacop/v3/symbol_node_test.rb in schemacop-3.0.9 vs test/unit/schemacop/v3/symbol_node_test.rb in schemacop-3.0.10
- old
+ new
@@ -1,22 +1,25 @@
require 'test_helper'
module Schemacop
module V3
class SymbolNodeTest < V3Test
- EXP_INVALID_TYPE = 'Invalid type, expected "Symbol".'.freeze
+ def self.invalid_type_error(type)
+ type = type.class unless type.class == Class
+ "Invalid type, got type \"#{type}\", expected \"Symbol\"."
+ end
def test_basic
schema :symbol
assert_validation :foo
assert_validation :'n0238n)Q(hqr3hrw3'
assert_validation 42 do
- error '/', EXP_INVALID_TYPE
+ error '/', SymbolNodeTest.invalid_type_error(Integer)
end
assert_validation '42' do
- error '/', EXP_INVALID_TYPE
+ error '/', SymbolNodeTest.invalid_type_error(String)
end
assert_json({})
end
def test_required
@@ -54,16 +57,16 @@
assert_validation(:bar)
# Even we put those types in the enum, they need to fail the validations,
# as they are not symbols
assert_validation('foo') do
- error '/', 'Invalid type, expected "Symbol".'
+ error '/', SymbolNodeTest.invalid_type_error(String)
end
assert_validation(1) do
- error '/', 'Invalid type, expected "Symbol".'
+ error '/', SymbolNodeTest.invalid_type_error(Integer)
end
assert_validation({ qux: 42 }) do
- error '/', 'Invalid type, expected "Symbol".'
+ error '/', SymbolNodeTest.invalid_type_error(Hash)
end
# These need to fail validation, as they are not in the enum list
assert_validation(:foo) do
error '/', 'Value not included in enum [1, 2, "foo", :bar, {:qux=>42}].'