PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/gems/facets-2.4.5/test/more/test_association.rb

https://bitbucket.org/mediashelf/fedora-migrator
Ruby | 38 lines | 29 code | 8 blank | 1 comment | 0 complexity | 535ecdf78c10c42e092c66f90d6158a9 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, IPL-1.0, AGPL-1.0, LGPL-3.0
  1. # Test facets/association.rb
  2. require 'facets/association.rb'
  3. require 'test/unit'
  4. class TC_Associations < Test::Unit::TestCase
  5. def setup
  6. @complex_hierarchy = [
  7. 'parent' >> 'child',
  8. 'childless',
  9. 'another_parent' >> [
  10. 'subchildless',
  11. 'subparent' >> 'subchild'
  12. ]
  13. ]
  14. end
  15. def test_ohash
  16. k,v = [],[]
  17. ohash = [ 'A' >> '3', 'B' >> '2', 'C' >> '1' ]
  18. ohash.each { |e1,e2| k << e1 ; v << e2 }
  19. assert_equal( ['A','B','C'], k )
  20. assert_equal( ['3','2','1'], v )
  21. end
  22. def test_complex
  23. complex = [ 'Drop Menu' >> [ 'Button 1', 'Button 2', 'Button 3' ], 'Help' ]
  24. assert_equal( 'Drop Menu', complex[0].index )
  25. end
  26. def test_associations
  27. complex = [ :a >> :b, :a >> :c ]
  28. assert_equal( [ :b, :c ], :a.associations )
  29. end
  30. end