Sha256: 07be6bb0855e24533d6cc74483409fe2496f9ee16793a1fc046592330ac9a272

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

require File.dirname(__FILE__) + '/spec_helper.rb'

describe "TableBodies" do
  
  before :all do
    @browser = Browser.new
  end

  before :each do
    @browser = Browser.new
    @browser.goto(TEST_HOST + "/tables.html")
  end
  
  describe "#length" do
    it "should return the correct number of table bodies (page context)" do
      @browser.bodies.length.should == 5
    end

    it "should return the correct number of table bodies (table context)" do
      @browser.table(:index, 1).bodies.length.should == 2
    end
  end
  
  describe "#[]" do
    it "should return the row at the given index (page context)" do
      @browser.bodies[1].id.should == "first"
      @browser.bodies[2].name.should == "second"
    end

    it "should return the row at the given index (table context)" do
      @browser.table(:index, 1).bodies[1].id.should == "first"
      @browser.table(:index, 1).bodies[2].name.should == "second"
    end
  end
  
  describe "#each" do
      it "should iterate through table bodies correctly (table context)" do
        @browser.bodies.each_with_index do |body, index|
          body.name.should == @browser.tbody(:index, index+1).name
          body.id.should == @browser.tbody(:index, index+1).id
        end
      end

      it "should iterate through table bodies correctly (table context)" do
        table = @browser.table(:index, 1)
        table.bodies.each_with_index do |body, index|
          body.name.should == table.body(:index, index+1).name
          body.id.should == table.body(:index, index+1).id
        end
      end      
    end
  
  after :all do
    @browser.close
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
celerity-0.0.4 spec/table_bodies_spec.rb