2010-04-05 01:11:28 -04:00
|
|
|
Shindo.tests('test_helper', 'meta') do
|
2010-05-06 00:40:21 -04:00
|
|
|
|
2010-05-26 20:37:27 -04:00
|
|
|
tests('#formats_kernel') do
|
2010-03-28 20:04:38 -04:00
|
|
|
|
|
|
|
tests('returns true') do
|
|
|
|
|
|
|
|
test('when format of value matches') do
|
2010-05-26 20:37:27 -04:00
|
|
|
formats_kernel({:a => :b}, {:a => Symbol})
|
2010-03-28 20:04:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
test('when format of nested array elements matches') do
|
2010-05-26 20:37:27 -04:00
|
|
|
formats_kernel({:a => [:b, :c]}, {:a => [Symbol]})
|
2010-03-28 20:04:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
test('when format of nested hash matches') do
|
2010-05-26 20:37:27 -04:00
|
|
|
formats_kernel({:a => {:b => :c}}, {:a => {:b => Symbol}})
|
2010-03-28 20:04:38 -04:00
|
|
|
end
|
|
|
|
|
2010-06-04 00:32:59 -04:00
|
|
|
test('when format of an array') do
|
|
|
|
formats_kernel([{:a => :b}], [{:a => Symbol}])
|
|
|
|
end
|
|
|
|
|
2011-09-28 15:24:40 -04:00
|
|
|
test('non strict extra data') do
|
|
|
|
formats_kernel({:a => :b, :b => :c}, {:a => Symbol}, true, false)
|
|
|
|
end
|
|
|
|
|
2010-03-28 20:04:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
tests('returns false') do
|
|
|
|
|
|
|
|
test('when format of value does not match') do
|
2010-05-26 20:37:27 -04:00
|
|
|
!formats_kernel({:a => :b}, {:a => String})
|
2010-03-28 20:04:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
test('when not all keys are checked') do
|
2010-05-26 20:37:27 -04:00
|
|
|
!formats_kernel({:a => :b}, {})
|
2010-03-28 20:04:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
test('when some keys do not appear') do
|
2010-05-26 20:37:27 -04:00
|
|
|
!formats_kernel({}, {:a => String})
|
2010-03-28 20:04:38 -04:00
|
|
|
end
|
|
|
|
|
2012-09-04 16:23:04 -04:00
|
|
|
test('when an array is expected but another data type is found') do
|
|
|
|
!formats_kernel({:a => 'not an array'}, {:a => []})
|
|
|
|
end
|
|
|
|
|
|
|
|
test('when a hash is expected but another data type is found') do
|
|
|
|
!formats_kernel({:a => 'not a hash'}, {:a => {}}, true, false)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2011-09-28 15:24:40 -04:00
|
|
|
test('non strict extra data') do
|
|
|
|
!formats_kernel({:a => :b, :b => :c}, {:z => Symbol}, true, false)
|
|
|
|
end
|
|
|
|
|
2010-03-28 20:04:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2010-05-06 00:40:21 -04:00
|
|
|
|
2010-03-28 20:04:38 -04:00
|
|
|
end
|