This repository has been archived by the owner on Jun 6, 2018. It is now read-only.
/
tfoot_spec.rb
92 lines (76 loc) · 3.44 KB
/
tfoot_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# encoding: utf-8
require File.expand_path("../spec_helper", __FILE__)
describe "TableFooter" do
before :each do
browser.goto(WatirSpec.url_for("tables.html"))
end
describe "#exists?" do
it "returns true if the table tfoot exists (page context)" do
browser.tfoot(:id, 'tax_totals').should exist
browser.tfoot(:id, /tax_totals/).should exist
browser.tfoot(:index, 0).should exist
browser.tfoot(:xpath, "//tfoot[@id='tax_totals']").should exist
end
it "returns true if the table tfoot exists (table context)" do
browser.table(:index, 0).tfoot(:id, 'tax_totals').should exist
browser.table(:index, 0).tfoot(:id, /tax_totals/).should exist
browser.table(:index, 0).tfoot(:index, 0).should exist
browser.table(:index, 0).tfoot(:xpath, "//tfoot[@id='tax_totals']").should exist
end
it "returns the first tfoot if given no args" do
browser.tfoot.should exist
end
it "returns false if the table tfoot doesn't exist (page context)" do
browser.tfoot(:id, 'no_such_id').should_not exist
browser.tfoot(:id, /no_such_id/).should_not exist
browser.tfoot(:index, 1337).should_not exist
browser.tfoot(:xpath, "//tfoot[@id='no_such_id']").should_not exist
end
it "returns false if the table tfoot doesn't exist (table context)" do
browser.table(:index, 0).tfoot(:id, 'no_such_id').should_not exist
browser.table(:index, 0).tfoot(:id, /no_such_id/).should_not exist
browser.table(:index, 0).tfoot(:index, 1337).should_not exist
browser.table(:index, 0).tfoot(:xpath, "//tfoot[@id='no_such_id']").should_not exist
end
it "raises TypeError when 'what' argument is invalid" do
lambda { browser.tfoot(:id, 3.14).exists? }.should raise_error(TypeError)
lambda { browser.table(:index, 0).tfoot(:id, 3.14).exists? }.should raise_error(TypeError)
end
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
lambda { browser.tfoot(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
lambda { browser.table(:index, 0).tfoot(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
end
end
describe "#[]" do
it "returns the row at the given index (page context)" do
browser.tfoot(:id, 'tax_totals')[0].id.should == 'tfoot_row_1'
browser.tfoot(:id, 'tax_totals')[0][1].text.should == '24 349'
browser.tfoot(:id, 'tax_totals')[0][2].text.should == '5 577'
end
it "returns the row at the given index (table context)" do
browser.table(:index, 0).tfoot(:id, 'tax_totals')[0].id.should == "tfoot_row_1"
browser.table(:index, 0).tfoot(:id, 'tax_totals')[0][1].text.should == '24 349'
browser.table(:index, 0).tfoot(:id, 'tax_totals')[0][2].text.should == '5 577'
end
end
describe "#row" do
it "finds the first row matching the selector" do
row = browser.tfoot(:id, 'tax_totals').row(:id => "tfoot_row_1")
row.id.should == "tfoot_row_1"
end
end
describe "#rows" do
it "finds rows matching the selector" do
rows = browser.tfoot(:id, 'tax_totals').rows(:id => "tfoot_row_1")
rows.size.should == 1
rows.first.id.should == "tfoot_row_1"
end
end
describe "#strings" do
it "returns the text of child cells" do
browser.tfoot(:id, 'tax_totals').strings.should == [
["Sum", "24 349", "5 577", "18 722"]
]
end
end
end