Changeset 283

Show
Ignore:
Timestamp:
10/25/08 10:05:58 (2 months ago)
Author:
pwh
Message:

Implemented tests for format_interface_name

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • nethorus/app/helpers/application_helper.rb

    r276 r283  
    5252 
    5353  def format_l3_interface(l2_interface) 
    54  
    5554 
    5655    # Check we've really been passed an L2Interface object 
  • nethorus/spec/helpers/application_helper_spec.rb

    r280 r283  
    4545   
    4646  it "should correctly generate a page subtitle, even when blank" do 
     47    params[:controller] = "foobar_controller" 
     48    params[:action] = "index" 
     49    generate_title_line_2.should eql("Foobar_controller") 
     50     
     51    params[:controller] = "foobar" 
     52    generate_title_line_2.should eql("Foobar") 
     53     
     54    params[:action] = "baz" 
     55    generate_title_line_2.should eql("Foobar: Baz") 
     56     
    4757    @subtitle = "foobar" 
    4858    generate_title_line_2.should eql("foobar") 
     
    130140  # TODO: Write tests for link_to_controller 
    131141  # TODO: Write tests for format_l2_interface 
    132   # TODO: Write tests for format_interface_name 
     142 
     143  it "should return 'none' if no Layer 2 interface address is passed, otherwise return the Layer 2 interface address" do 
     144    format_l2_interface(nil).should eql("none") 
     145    format_l2_interface("").should eql("none") 
     146    format_l2_interface("foobar").should eql("foobar") 
     147  end 
     148   
     149  it "should return an empty string if no interface name is passed, the interface name if the description is blank, or the interface name and description if both have been passed" do 
     150    format_interface_name(nil, nil).should eql("") 
     151    format_interface_name("", "").should eql("") 
     152    format_interface_name("foo", "").should eql("foo") 
     153    format_interface_name("", "bar").should eql("") 
     154    format_interface_name("foo", "bar").should eql("foo (bar)") 
     155  end 
     156  
     157  it "should return 'Unknown' for an unknown Layer 2 interface type, otherwise return the interface type" do 
     158    format_l2_interface_type(nil).should eql("Unknown") 
     159    format_l2_interface_type("").should eql("Unknown") 
     160    format_l2_interface_type("foobar").should eql("foobar") 
     161  end 
     162   
     163 
    133164  # TODO: Write tests for format_site 
    134   # TODO: Write tests for format_l2_interface_type 
    135165  # TODO: Write tests for remaining functions in generate_title_line_2 
    136166end