spec/lib/mohawk/accessors/table_spec.rb in mohawk-0.0.3 vs spec/lib/mohawk/accessors/table_spec.rb in mohawk-0.0.4

- old
+ new

@@ -1,7 +1,6 @@ require 'spec_helper' -require 'ffi' class TableScreen include Mohawk window(:id => nil) @@ -19,23 +18,10 @@ @text = text @row = row end end -module FFI - module Library - def ffi_lib(*names) - end - - def ffi_libraries - end - - def attach_function(name, func, args, returns = nil, options = nil) - end - end -end - describe Mohawk::Accessors::Table do let(:screen) { TableScreen.new } let(:window) { double("RAutomation Window") } let(:table) { double("Table") } @@ -57,13 +43,16 @@ table.should_receive(:select).with "John Elway" screen.top = "John Elway" end it "has rows" do - fake_rows = [FakeTableRow.new("First Row", 0), FakeTableRow.new("Second Row", 1)] - expected_rows = fake_rows.map {|r| {:text => r.text, :row => r.row} } - table.should_receive(:rows).and_return(fake_rows) + first_row = FakeTableRow.new "First Row", 0 + second_row = FakeTableRow.new "Second Row", 1 + expected_rows = [first_row, second_row].map {|r| {:text => r.text, :row => r.row} } + table.should_receive(:row_count).and_return(2) + RAutomation::Adapter::MsUia::Row.should_receive(:new).with(table, :index => 0).and_return(first_row) + RAutomation::Adapter::MsUia::Row.should_receive(:new).with(table, :index => 1).and_return(second_row) screen.top.map(&:to_hash).should eq(expected_rows) end it "has headers" do expected_headers = ["first header", "second header"] @@ -78,11 +67,11 @@ describe Mohawk::Accessors::TableRow do let(:table_row) { double("RAutomation TableRow") } before(:each) do - table.should_receive(:row).with(:index => 0).and_return(table_row) + RAutomation::Adapter::MsUia::Row.should_receive(:new).with(table, :index => 0).and_return(table_row) table_row.stub(:row).and_return 0 end it "can get an individual row" do screen.top[0].should_not be_nil @@ -105,11 +94,13 @@ end it "can get cell values by header name" do RAutomation::Adapter::MsUia::UiaDll.should_receive(:table_headers).and_return(["First Header", "Second Header"]) table.should_receive(:search_information) - expected_cells = [FakeTableRow.new("Item 1", 0), FakeTableRow.new("Item 2", 1)] - table_row.should_receive(:cells).and_return(expected_cells) + + expected_cell = double('RAutomation Cell') + expected_cell.should_receive(:text).and_return('Item 2') + RAutomation::Adapter::MsUia::Cell.should_receive(:new).with(table_row, :index => 1).and_return(expected_cell) screen.top[0].second_header.should eq("Item 2") end it "clearly lets you know if a header is not there" do RAutomation::Adapter::MsUia::UiaDll.should_receive(:table_headers).and_return(["First Header", "Second Header"])