watir-or 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@ module ObjectRepository
7
7
  @id = id
8
8
  @description = description
9
9
  @type = type
10
+ normalize_whats!(whats)
10
11
  @locator = Hash[*hows.zip(whats).flatten]
11
12
  end
12
13
 
@@ -17,6 +18,14 @@ module ObjectRepository
17
18
  def ==(other)
18
19
  @id == other.id && @type == other.type && @description == other.description && @locator == other.locator
19
20
  end
21
+
22
+ private
23
+
24
+ def normalize_whats!(whats)
25
+ whats.map! do |what|
26
+ what =~ /^\/(.*)\/$/ ? what = Regexp.new($1) : what
27
+ end
28
+ end
20
29
  end
21
30
 
22
31
  class CustomElement
@@ -7,7 +7,7 @@ module ObjectRepository
7
7
  if options.nil?
8
8
  read_worksheet(Spreadsheet.open(file).worksheet(0), &block)
9
9
  elsif options[:worksheet].is_a?(String)
10
- read_worksheet(Spreadsheet.open(file).worksheet(options[:tab]), &block)
10
+ read_worksheet(Spreadsheet.open(file).worksheet(options[:worksheet]), &block)
11
11
  elsif options[:worksheet] == :all
12
12
  Spreadsheet.open(file).worksheets.each { |worksheet|
13
13
  read_worksheet(worksheet, &block)
@@ -27,7 +27,7 @@ describe "Read xls-repository" do
27
27
 
28
28
  context "Read special worksheet" do
29
29
  before(:all) do
30
- @repository = ObjectRepository::Repository.new("spec/test.xls", nil, :tab => "special worksheet")
30
+ @repository = ObjectRepository::Repository.new("spec/test.xls", nil, :worksheet => "special worksheet")
31
31
  end
32
32
 
33
33
  it "should read element on special workheet" do
@@ -39,7 +39,7 @@ describe "Read xls-repository" do
39
39
 
40
40
  context "Read all worksheets" do
41
41
  before(:all) do
42
- @repository = ObjectRepository::Repository.new("spec/test.xls", nil, :tab => :all)
42
+ @repository = ObjectRepository::Repository.new("spec/test.xls", nil, :worksheet => :all)
43
43
  end
44
44
 
45
45
  it "should read all elements on all workheets" do
data/spec/test.xls CHANGED
Binary file
@@ -13,15 +13,23 @@ describe "WatirConverter" do
13
13
  built.should == 'select_list(:index=>1, :text=>"test text")'
14
14
  end
15
15
 
16
- it "build watir object which has one parent" do
17
- element = @repository.elements.find {|el| el.id == "with parent"}
16
+ it "build element with regexp" do
17
+ element = @repository.elements.find {|el| el.id == "with regexp what"}
18
18
  built = ObjectRepository::ElementConverter::Watir.build_element(element, @repository)
19
- built.should == 'div(:index,1).div(:index,3)'
19
+ built.should == 'text_field(:text,/regexp/)'
20
20
  end
21
21
 
22
- it "2 level hierarchy" do
23
- element = @repository.elements.find {|el| el.id == "2 level hierarchy"}
24
- built = ObjectRepository::ElementConverter::Watir.build_element(element, @repository)
25
- built.should == 'div(:index,1).div(:index,3).div(:index,5)'
22
+ context "hierarchy" do
23
+ it "watir object which has one parent" do
24
+ element = @repository.elements.find {|el| el.id == "with parent"}
25
+ built = ObjectRepository::ElementConverter::Watir.build_element(element, @repository)
26
+ built.should == 'div(:index,1).div(:index,3)'
27
+ end
28
+
29
+ it "2 level" do
30
+ element = @repository.elements.find {|el| el.id == "2 level hierarchy"}
31
+ built = ObjectRepository::ElementConverter::Watir.build_element(element, @repository)
32
+ built.should == 'div(:index,1).div(:index,3).div(:index,5)'
33
+ end
26
34
  end
27
35
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ivan Kabluchkov
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-30 00:00:00 +04:00
17
+ date: 2010-10-17 00:00:00 +04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency