vendor/plugins/assert_request/test/unit/param_rules_test.rb
def add_child(parent, required, name)
    old_num_children = parent.children.length
    if required
      parent.must_have name
    else
      parent.may_have name
    end
    assert_equal old_num_children+1, parent.children.length
    # Here we presume that the child got added to the end of the children.
    child = parent.children.last
    assert_equal name.to_s, child.name
    assert_equal parent, child.parent
    assert child.children.empty?
    if required
      assert child.required?    
    else
      assert ! child.required?
    end
    child
  end
# Add a new child with the given name and required status to the given
# parent.
Add a new child with the given name and required status to the given
parent.
Add a new child with the given name and required status to the given parent .
def add_child(parent, required, name)
    old_num_children = parent.children.length
    if required
      parent.must_have name
    else
      parent.may_have name
    end
    assert_equal old_num_children+1, parent.children.length
    child = parent.children.last
    assert_equal name.to_s, child.name
    assert_equal parent, child.parent
    assert child.children.empty?
    if required
      assert child.required?    
    else
      assert ! child.required?
    end
    child
  end
def add_child ( parent , required , name ) old_num_children = parent . children . length if required parent . must_have name else parent . may_have name end assert_equal old_num_children + 1 , parent . children . length child = parent . children . last assert_equal name . to_s , child . name assert_equal parent , child . parent assert child . children . empty? if required assert child . required? else assert ! child . required? end child end
Add a new child with the given name and required status to the given
parent.
Add a new child with the given name and required status to the given parent .
# Here we presume that the child got added to the end of the children.
parent
required
name