Sha256: 258f8463b361fed96741fbf1391a015762882ec7991324f233202c70e64e6be1

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe Symbiont::WebObjects::Table do
  describe "implementation" do
    let(:table_object) { double('table_object') }
    
    context "on the watir platform" do
      let(:watir_table) { Symbiont::WebObjects::Table.new(table_object) }
      
      it "should return a table row when indexed" do
        table_object.stub(:[]).with(1).and_return(table_object)
        watir_table[1].should be_instance_of Symbiont::WebObjects::TableRow
      end
      
      it "should return the first row" do
        table_object.stub(:[]).with(0).and_return(table_object)
        watir_table.first_row.should be_instance_of Symbiont::WebObjects::TableRow
      end
      
      it "should return the last row" do
        table_object.stub(:[]).with(-1).and_return(table_object)
        watir_table.last_row.should be_instance_of Symbiont::WebObjects::TableRow
      end
      
      it "should return the number of rows" do
        table_object.should_receive(:wd).and_return(table_object)
        table_object.should_receive(:find_elements).with(:xpath, ".//child::tr").and_return(table_object)
        table_object.should_receive(:size).and_return(2)
        watir_table.rows.should == 2
      end
      
      it "should iterate over the table rows" do
        watir_table.should_receive(:rows).and_return(2)
        table_object.stub(:[]).and_return(table_object)
        count = 0
        watir_table.each { |e| count += 1 }
        count.should == 2
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
symbiont-0.1.1 spec/symbiont/web_objects/table_spec.rb