2010-04-05 01:11:28 -04:00
|
|
|
Shindo.tests('test_helper', 'meta') do
|
2010-05-06 00:40:21 -04:00
|
|
|
|
|
|
|
tests('#has_error') do
|
|
|
|
|
|
|
|
tests('returns true') do
|
|
|
|
|
|
|
|
test('when expected error is raised') do
|
|
|
|
has_error(StandardError) { raise StandardError.new }
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('returns false') do
|
|
|
|
|
|
|
|
test('when no error is raised') do
|
|
|
|
!has_error(StandardError) {}
|
|
|
|
end
|
|
|
|
|
|
|
|
test('when a different error is raised') do
|
|
|
|
begin
|
|
|
|
!has_error(StandardError) { raise Interrupt.new }
|
|
|
|
false
|
|
|
|
rescue Interrupt
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('#has_format') do
|
2010-03-28 20:04:38 -04:00
|
|
|
|
|
|
|
tests('returns true') do
|
|
|
|
|
|
|
|
test('when format of value matches') do
|
2010-05-06 00:40:21 -04:00
|
|
|
has_format({:a => :b}, {:a => Symbol})
|
2010-03-28 20:04:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
test('when format of nested array elements matches') do
|
2010-05-06 00:40:21 -04:00
|
|
|
has_format({:a => [:b, :c]}, {:a => [Symbol]})
|
2010-03-28 20:04:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
test('when format of nested hash matches') do
|
2010-05-06 00:40:21 -04:00
|
|
|
has_format({:a => {:b => :c}}, {:a => {:b => Symbol}})
|
2010-03-28 20:04:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('returns false') do
|
|
|
|
|
|
|
|
test('when format of value does not match') do
|
2010-05-06 00:40:21 -04:00
|
|
|
!has_format({:a => :b}, {:a => String})
|
2010-03-28 20:04:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
test('when not all keys are checked') do
|
2010-05-06 00:40:21 -04:00
|
|
|
!has_format({:a => :b}, {})
|
2010-03-28 20:04:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
test('when some keys do not appear') do
|
2010-05-06 00:40:21 -04:00
|
|
|
!has_format({}, {:a => String})
|
2010-03-28 20:04:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2010-05-06 00:40:21 -04:00
|
|
|
|
2010-03-28 20:04:38 -04:00
|
|
|
end
|