1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/helpers/formats_helper_tests.rb
Frederick Cheung 519efbf179 [Core] fix format_helper assuming p returns nil
on ruby 1.9 it returns the printed string so
x = foo || p("foo was false")

always evaluates to something truthy
2012-09-04 21:26:48 +01:00

60 lines
1.5 KiB
Ruby

Shindo.tests('test_helper', 'meta') do
tests('#formats_kernel') do
tests('returns true') do
test('when format of value matches') do
formats_kernel({:a => :b}, {:a => Symbol})
end
test('when format of nested array elements matches') do
formats_kernel({:a => [:b, :c]}, {:a => [Symbol]})
end
test('when format of nested hash matches') do
formats_kernel({:a => {:b => :c}}, {:a => {:b => Symbol}})
end
test('when format of an array') do
formats_kernel([{:a => :b}], [{:a => Symbol}])
end
test('non strict extra data') do
formats_kernel({:a => :b, :b => :c}, {:a => Symbol}, true, false)
end
end
tests('returns false') do
test('when format of value does not match') do
!formats_kernel({:a => :b}, {:a => String})
end
test('when not all keys are checked') do
!formats_kernel({:a => :b}, {})
end
test('when some keys do not appear') do
!formats_kernel({}, {:a => String})
end
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
test('non strict extra data') do
!formats_kernel({:a => :b, :b => :c}, {:z => Symbol}, true, false)
end
end
end
end