$:.unshift(File.dirname(__FILE__)) require 'abstract_unit' class JudeBaseTest < Test::Unit::TestCase def setup super end def test_members jude_project = JudeApiLoader.load("#{jude_dir}/base.jude") assert_equal 8, jude_project.members.size jude_project.members.each {|x| assert_same jude_project.members, x.members } end def test_search jude_project = JudeApiLoader.load("#{jude_dir}/base.jude") pp jude_project.search assert_equal 8, jude_project.search.size end def test_search_name searched = JudeApiLoader.load("#{jude_dir}/base.jude").search(:name => "User") assert_equal 1, searched.size assert_equal "User", searched.first.name end def test_search_id searched = JudeApiLoader.load("#{jude_dir}/base.jude"). search(:id => "4d-fcijzpfi--w5ebkp--jss66m-83d178913eb2e8154266c52d36b14e8e") assert_equal 1, searched.size assert_equal "4d-fcijzpfi--w5ebkp--jss66m-83d178913eb2e8154266c52d36b14e8e", searched.first.id end def test_search_id_and_name project = JudeApiLoader.load("#{jude_dir}/base.jude") searched = project.search(:name => 'User', :id => "4d-fcijzpfi--w5ebkp--jss66m-83d178913eb2e8154266c52d36b14e8e") assert searched.empty? searched = project.search(:name => 'package', :id => "4d-fcijzpfi--w5ebkp--jss66m-83d178913eb2e8154266c52d36b14e8e") assert 1, searched.size end def test_search_block searched = JudeApiLoader.load("#{jude_dir}/base.jude").search{|a| a.name == "User" rescue false} assert_equal 1, searched.size assert_equal "User", searched.first.name end def test_search_xxxxs project = JudeApiLoader.load("#{jude_dir}/base.jude") searched = project.search_classes assert_equal 3, searched.size assert_equal ["Group","User", "subsystem"], searched.collect{|x|x.name}.sort end def test_search_with_args project = JudeApiLoader.load("#{jude_dir}/base.jude") searched = project.search_classes{|x|x.name == "User"} assert_equal 1, searched.size assert_equal "User", searched.first.name searched = project.search_classes(:name => "User") assert_equal 1, searched.size assert_equal "User", searched.first.name end end