Sha256: 8bbc4d610a83cf20ca06a76148efaeae8550a757c93ce139f1b9d371306defc0

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 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 a row using text from the first column" do
        table_object.stub(:[]).with("row_text").and_return(table_object)
        table_object.should_receive(:rows).and_return(table_object)
        table_object.should_receive(:find_index).and_return("row_text")
        watir_table["row_text"].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.2 spec/symbiont/web_objects/table_spec.rb