spec/table_row_spec.rb in celerity-0.0.3 vs spec/table_row_spec.rb in celerity-0.0.4

- old
+ new

@@ -1,35 +1,41 @@ require File.dirname(__FILE__) + '/spec_helper.rb' -describe TableRow do +describe "TableRow" do before :all do - @browser = IE.new - add_spec_checker(@browser) + @browser = Browser.new end before :each do - @browser = IE.new + @browser = Browser.new @browser.goto(TEST_HOST + "/tables.html") end describe "#exists?" do it "should return true if the table row exists" do @browser.row(:id, "outer_first").should exist @browser.row(:id, /outer_first/).should exist @browser.row(:index, 1).should exist @browser.row(:xpath, "//tr[@id='outer_first']") end + it "should return true if the element exists (default how = :id)" do @browser.row("outer_last").should exist end + it "should return false if the table row exists" do - + @browser.row(:id, "no_such_id").should_not exist + @browser.row(:id, /no_such_id/).should_not exist + @browser.row(:index, 1337).should_not exist + @browser.row(:xpath, "//tr[@id='no_such_id']") end + it "should raise ArgumentError when 'what' argument is invalid" do lambda { @browser.row(:id, 3.14).exists? }.should raise_error(ArgumentError) end + it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do lambda { @browser.row(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException) end end @@ -49,18 +55,36 @@ @browser.table(:id, 'inner').rows.length.should == 1 end end describe "#[]" do - it "should " do # FIXME: description + it "should return the nth cell of the parent row" do @browser.table(:id, 'outer').row(:index, 1)[1].text.should == "Table 1, Row 1, Cell 1" @browser.table(:id, 'outer')[1][1].text.should == "Table 1, Row 1, Cell 1" @browser.table(:id, 'outer')[3][1].text.should == "Table 1, Row 3, Cell 1" end + + it "should raise UnknownCellException if the index is out of bounds" do + lambda { @browser.table(:id, 'outer').row(:index, 1)[1337] }.should raise_error(UnknownCellException) + lambda { @browser.table(:id, 'outer')[1][1337] }.should raise_error(UnknownCellException) + end end + describe "#child_cell" do + it "should return the nth cell of the parent row" do + @browser.table(:id, 'outer').row(:index, 1).child_cell(1).text.should == "Table 1, Row 1, Cell 1" + @browser.table(:id, 'outer')[1].child_cell(1).text.should == "Table 1, Row 1, Cell 1" + @browser.table(:id, 'outer')[3].child_cell(1).text.should == "Table 1, Row 3, Cell 1" + end + + it "should raise UnknownCellException if the index is out of bounds" do + lambda { @browser.table(:id, 'outer').row(:index, 1).child_cell(1337) }.should raise_error(UnknownCellException) + lambda { @browser.table(:id, 'outer')[1].child_cell(1337) }.should raise_error(UnknownCellException) + end + end + describe "#each" do - it "should " do # FIXME: description + it "should iterate correctly through the cells of the row" do index = 1 @browser.table(:id, 'outer')[2].each do |c| case index when 1 c.text.should == "Table 1, Row 2, Cell 1"