domkey 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/.gitmodules +3 -0
- data/README.md +2 -4
- data/Rakefile +4 -1
- data/lib/domkey/version.rb +1 -1
- data/lib/domkey/view.rb +42 -4
- data/lib/domkey/view/cargo.rb +92 -0
- data/lib/domkey/view/checkbox_group.rb +75 -0
- data/lib/domkey/view/label_mapper.rb +18 -0
- data/lib/domkey/view/labeled_group.rb +50 -0
- data/lib/domkey/view/page_object.rb +85 -85
- data/lib/domkey/view/page_object_collection.rb +31 -49
- data/lib/domkey/view/radio_group.rb +70 -0
- data/lib/domkey/view/watir_widget.rb +106 -0
- data/lib/domkey/view/widgetry_package.rb +48 -0
- data/spec/checkbox_group_spec.rb +81 -0
- data/spec/html/test.html +61 -5
- data/spec/labeled_group_spec.rb +118 -0
- data/spec/page_object_collection_spec.rb +14 -14
- data/spec/page_object_decorators_spec.rb +41 -52
- data/spec/page_object_spec.rb +23 -18
- data/spec/page_spec.rb +12 -12
- data/spec/radio_group_spec.rb +85 -0
- data/spec/selenium_webdriver_api_example.rb +42 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/view_cargo_spec.rb +106 -0
- data/spec/view_dom_spec.rb +50 -16
- data/spec/view_doms_spec.rb +7 -7
- data/spec/watir_widget_select_spec.rb +176 -0
- data/spec/watirspec_pageobjects/watirspec_spec.rb +12 -0
- metadata +24 -2
data/spec/page_spec.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
describe Domkey::View do
|
4
|
+
|
5
|
+
class DomIspackage
|
4
6
|
include Domkey::View
|
5
|
-
#pageobject is
|
7
|
+
#pageobject is package
|
6
8
|
dom(:street) { text_field(id: 'street1') }
|
7
9
|
dom(:city) { text_field(id: 'city1') }
|
8
10
|
end
|
@@ -37,16 +39,14 @@ module DomkeyExample
|
|
37
39
|
# dom(:city) { text_field(id: 'city') }
|
38
40
|
#end
|
39
41
|
end
|
40
|
-
end
|
41
42
|
|
42
|
-
describe Domkey::View do
|
43
43
|
|
44
44
|
before :all do
|
45
|
-
|
45
|
+
goto_html("test.html")
|
46
46
|
end
|
47
47
|
|
48
|
-
it '
|
49
|
-
view =
|
48
|
+
it 'dom is package' do
|
49
|
+
view = DomIspackage.new
|
50
50
|
view.should respond_to(:street)
|
51
51
|
view.street.should be_kind_of(Domkey::View::PageObject)
|
52
52
|
|
@@ -56,14 +56,14 @@ describe Domkey::View do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'dom is hash of dom' do
|
59
|
-
view =
|
59
|
+
view = DomIsHashOfDom.new
|
60
60
|
|
61
61
|
view.should respond_to(:address)
|
62
62
|
|
63
|
-
view.address.
|
64
|
-
view.address.
|
63
|
+
view.address.package.should respond_to(:each_pair)
|
64
|
+
view.address.package.should_not be_empty
|
65
65
|
|
66
|
-
view.address.
|
66
|
+
view.address.package.each_pair do |k, v|
|
67
67
|
k.should be_kind_of(Symbol)
|
68
68
|
v.should be_kind_of(Domkey::View::PageObject) #should respond to set and value
|
69
69
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Domkey::View::RadioGroup do
|
4
|
+
|
5
|
+
class CollectionAsPageObjectRadioGroupView
|
6
|
+
include Domkey::View
|
7
|
+
|
8
|
+
# one named radio group
|
9
|
+
def group
|
10
|
+
RadioGroup.new -> { radios(name: 'tool') }
|
11
|
+
end
|
12
|
+
|
13
|
+
# no good. collection resolves to more than one coherent group
|
14
|
+
def groups
|
15
|
+
RadioGroup.new -> { radios(name: /^group/) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
before :all do
|
20
|
+
goto_html("test.html")
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'two groups example' do
|
24
|
+
v = CollectionAsPageObjectRadioGroupView.new
|
25
|
+
expect { v.groups.to_a.size }.to raise_error
|
26
|
+
expect { v.groups.map { |e| e } }.to raise_error
|
27
|
+
expect { v.groups.count }.to raise_error
|
28
|
+
end
|
29
|
+
|
30
|
+
context "OptionSelectable object single" do
|
31
|
+
# OptionSelectable object is an object that responds to options and is selectable by its optioins;
|
32
|
+
# RadioGroup, Select, CheckboxGroup. CheckboxGroup acts like Multi Select, RadioGroup acts like Single Select
|
33
|
+
|
34
|
+
before :each do
|
35
|
+
goto_html("test.html")
|
36
|
+
|
37
|
+
@v = CollectionAsPageObjectRadioGroupView.new
|
38
|
+
@v.group.count.should == 3
|
39
|
+
@v.group.to_a.each { |e| e.should be_kind_of(Domkey::View::PageObject) }
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'initial value on test page' do
|
43
|
+
@v.group.value.should eql ['other']
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'set value attribute by default. value returns that value attribute' do
|
47
|
+
@v.group.set 'tomato'
|
48
|
+
@v.group.value.should eql ['tomato']
|
49
|
+
@v.group.set /^oth/
|
50
|
+
@v.group.value.should eql ['other']
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'set array of value attribute. last value wins' do
|
54
|
+
@v.group.set ['tomato']
|
55
|
+
@v.group.value.should eql ['tomato']
|
56
|
+
|
57
|
+
@v.group.set ['other', 'tomato', /cucu/]
|
58
|
+
@v.group.value.should eql ['cucumber']
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'set false has no effect. value is initial value on the page' do
|
62
|
+
@v.group.set false
|
63
|
+
@v.group.value.should eql ['other']
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'set empty array clears all. value is empty array' do
|
67
|
+
@v.group.set []
|
68
|
+
@v.group.value.should eql ['other']
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'set value string not found error' do
|
72
|
+
expect { @v.group.set 'foobar' }.to raise_error
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'set value regexp not found error' do
|
76
|
+
expect { @v.group.set /balaba/ }.to raise_error
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'options' do
|
80
|
+
@v.group.options.should eql ["cucumber", "tomato", "other"]
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Watir API is the Bee's Knees
|
4
|
+
# but you can use lower level Selenium::WebDriver API for container and package definitions
|
5
|
+
# you will need to override set and value methods to delegate to Selenium::WebDriver::Element
|
6
|
+
|
7
|
+
describe 'Selenium::WebDriver API Example' do
|
8
|
+
|
9
|
+
before :all do
|
10
|
+
Domkey.browser.goto("file://" + __dir__ + "/../html/test.html")
|
11
|
+
@driverpackage = -> { Domkey.browser.driver }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when container is selenium webdriver and' do
|
15
|
+
|
16
|
+
it 'package is package' do
|
17
|
+
package = lambda { find_element(id: 'street1') }
|
18
|
+
street = Domkey::View::PageObject.new package, @driverpackage
|
19
|
+
|
20
|
+
street.package.should be_kind_of(Proc)
|
21
|
+
street.element.should be_kind_of(Selenium::WebDriver::Element) #one default element
|
22
|
+
|
23
|
+
street.element.send_keys 'Lamar'
|
24
|
+
street.element.attribute('value').should eql 'Lamar'
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'package is pageobject' do
|
28
|
+
# setup
|
29
|
+
webdriver_element = lambda { find_element(id: 'street1') }
|
30
|
+
|
31
|
+
pageobject = Domkey::View::PageObject.new webdriver_element, @driverpackage
|
32
|
+
street = Domkey::View::PageObject.new pageobject, @driverpackage
|
33
|
+
|
34
|
+
street.package.should be_kind_of(Proc)
|
35
|
+
street.element.should be_kind_of(Selenium::WebDriver::Element)
|
36
|
+
|
37
|
+
street.element.clear
|
38
|
+
street.element.send_keys 'zooom'
|
39
|
+
street.element.attribute('value').should eql 'zooom'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,7 +7,24 @@ end
|
|
7
7
|
require 'domkey'
|
8
8
|
SimpleCov.command_name "test:units"
|
9
9
|
|
10
|
+
module DomkeySpecHelper
|
11
|
+
|
12
|
+
def goto_watirspec file
|
13
|
+
goto("file://" + __dir__ + "/watirspec/html/#{file}")
|
14
|
+
end
|
15
|
+
|
16
|
+
def goto_html file
|
17
|
+
goto("file://" + __dir__ + "/html/#{file}")
|
18
|
+
end
|
19
|
+
|
20
|
+
def goto path
|
21
|
+
Domkey.browser.goto path
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
10
26
|
RSpec.configure do |config|
|
27
|
+
config.include DomkeySpecHelper
|
11
28
|
config.after :all do
|
12
29
|
Domkey.browser.close
|
13
30
|
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Domkey::View::Cargo do
|
4
|
+
|
5
|
+
class AddressView
|
6
|
+
include Domkey::View
|
7
|
+
dom(:city) { text_field(id: 'city1') }
|
8
|
+
dom(:street) { text_field(id: 'street1') }
|
9
|
+
|
10
|
+
# semantic descriptor that returns another view
|
11
|
+
# the other view has PageObjects that participate in this view
|
12
|
+
def shipping
|
13
|
+
ShippingAddressView.new
|
14
|
+
end
|
15
|
+
|
16
|
+
# semantic descriptor that returns PageObject
|
17
|
+
def fruit
|
18
|
+
CheckboxGroup.new -> { checkboxes(name: 'fruit') }
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
class ShippingAddressView
|
24
|
+
include Domkey::View
|
25
|
+
dom(:city) { text_field(id: 'city2') }
|
26
|
+
dom(:street) { text_field(id: 'street2') }
|
27
|
+
|
28
|
+
def delivery_date
|
29
|
+
DateView.new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class DateView
|
34
|
+
include Domkey::View
|
35
|
+
dom(:month) { text_field(id: 'month_field') }
|
36
|
+
end
|
37
|
+
|
38
|
+
before :each do
|
39
|
+
goto_html("test.html")
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'view within pageobject' do
|
43
|
+
model = {city: 'Austin',
|
44
|
+
street: 'Lamar'}
|
45
|
+
|
46
|
+
cargo = Domkey::View::Cargo.new model: model, view: AddressView.new
|
47
|
+
cargo.set
|
48
|
+
extracted = cargo.value
|
49
|
+
extracted.should eql model
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'view within view' do
|
53
|
+
model = {city: 'Austin',
|
54
|
+
street: 'Lamar',
|
55
|
+
shipping: {city: 'Georgetown',
|
56
|
+
street: 'Austin'}
|
57
|
+
}
|
58
|
+
|
59
|
+
cargo = Domkey::View::Cargo.new model: model, view: AddressView.new
|
60
|
+
cargo.set
|
61
|
+
extracted = cargo.value
|
62
|
+
extracted.should eql model
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'view view view' do
|
66
|
+
model = {city: 'Austin',
|
67
|
+
street: 'Lamar',
|
68
|
+
shipping: {city: 'Georgetown',
|
69
|
+
street: 'Austin',
|
70
|
+
# this is view within a view within original view
|
71
|
+
delivery_date: {month: 'delivery thing'}}
|
72
|
+
}
|
73
|
+
|
74
|
+
cargo = Domkey::View::Cargo.new model: model, view: AddressView.new
|
75
|
+
cargo.set
|
76
|
+
extracted = cargo.value
|
77
|
+
extracted.should eql model
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'cargo' do
|
81
|
+
model = {city: 'Mordor'}
|
82
|
+
|
83
|
+
view = AddressView.new
|
84
|
+
cargo = Domkey::View::Cargo.new view: view, model: model
|
85
|
+
cargo.set
|
86
|
+
scraped_model = cargo.value
|
87
|
+
|
88
|
+
scraped_model.should eql model
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'pageobject' do
|
92
|
+
|
93
|
+
model = {city: 'Austin', fruit: ['tomato', 'other']}
|
94
|
+
cargo = AddressView.cargo model
|
95
|
+
|
96
|
+
# default values when page loads before setting the values
|
97
|
+
default_page_values = {:city=>"id city class city", :fruit=>["other"]}
|
98
|
+
cargo.value.should eql default_page_values
|
99
|
+
cargo.set
|
100
|
+
|
101
|
+
extracted_model = cargo.value
|
102
|
+
extracted_model.should eql model
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
data/spec/view_dom_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
|
2
|
+
|
3
|
+
describe Domkey::View do
|
3
4
|
|
4
5
|
class SingleDom
|
5
6
|
include Domkey::View
|
@@ -15,32 +16,65 @@ module DomkeyExample
|
|
15
16
|
dom(:street) { text_field(class: 'street1') }
|
16
17
|
end
|
17
18
|
|
18
|
-
end
|
19
|
-
|
20
|
-
describe Domkey::View do
|
21
|
-
|
22
19
|
before :all do
|
23
|
-
|
20
|
+
goto_html("test.html")
|
24
21
|
end
|
25
22
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
view
|
33
|
-
|
34
|
-
|
23
|
+
context 'dom for single element' do
|
24
|
+
|
25
|
+
before :all do
|
26
|
+
@view = SingleDom.new
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'view responds to dom' do
|
30
|
+
@view.should respond_to(:street)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'dom returns PageObject' do
|
34
|
+
@view.street.should be_kind_of(Domkey::View::PageObject)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'dom set and value' do
|
38
|
+
@view.street.value.should == ''
|
39
|
+
@view.street.set 'bla'
|
40
|
+
@view.street.value.should == 'bla'
|
41
|
+
end
|
35
42
|
end
|
36
43
|
|
44
|
+
context 'view method returns view that acts like pageobject' do
|
45
|
+
before :all do
|
46
|
+
@view = SingleDom.new
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'view semantic descriptor returns view' do
|
50
|
+
@view.container.should be_kind_of(Domkey::View)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'view within view is a page object' do
|
54
|
+
@view.container.street.should be_kind_of(Domkey::View::PageObject)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'value requires args' do
|
58
|
+
expect { @view.container.value }.to raise_error
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'setting and value args' do
|
62
|
+
@view.container.set street: 'Nowy Świat'
|
63
|
+
|
64
|
+
v = @view.container.value :street
|
65
|
+
v.should eql({:street=>"Nowy Świat"})
|
66
|
+
|
67
|
+
v = @view.container.value [:street]
|
68
|
+
v.should eql({:street=>"Nowy Świat"})
|
69
|
+
end
|
70
|
+
end
|
37
71
|
end
|
38
72
|
|
39
73
|
#require 'benchmark'
|
40
74
|
#Benchmark.bm do |bm|
|
41
75
|
# howmany = 50
|
42
76
|
# # setup browser
|
43
|
-
#
|
77
|
+
# goto_html("test.html")
|
44
78
|
# view = DomkeyExample::SingleDom.new Domkey.browser
|
45
79
|
# bm.report('domkey') do
|
46
80
|
# howmany.times do
|
data/spec/view_doms_spec.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
describe Domkey::View do
|
4
|
+
|
5
|
+
class DomsExample
|
4
6
|
include Domkey::View
|
5
7
|
doms(:streets) { text_fields(class: 'street1') }
|
6
8
|
end
|
7
|
-
end
|
8
9
|
|
9
|
-
describe Domkey::View do
|
10
10
|
|
11
11
|
before :all do
|
12
|
-
|
12
|
+
goto_html("test.html")
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'doms collection' do
|
16
|
-
view =
|
16
|
+
view = DomsExample.new
|
17
17
|
view.should respond_to(:streets)
|
18
18
|
view.streets.should be_kind_of(Domkey::View::PageObjectCollection)
|
19
19
|
view.streets.each { |e| e.should be_kind_of(Domkey::View::PageObject) }
|
@@ -32,7 +32,7 @@ end
|
|
32
32
|
#Benchmark.bm do |bm|
|
33
33
|
# howmany = 50
|
34
34
|
# # setup browser
|
35
|
-
#
|
35
|
+
# goto_html("test.html")
|
36
36
|
# view = DomkeyExample::Doms.new Domkey.browser
|
37
37
|
# bm.report('domkey') do
|
38
38
|
# howmany.times do
|
@@ -0,0 +1,176 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Domkey::View::WatirWidget do
|
4
|
+
|
5
|
+
context Watir::Select do
|
6
|
+
|
7
|
+
context "Multi" do
|
8
|
+
|
9
|
+
before :all do
|
10
|
+
@object = Domkey.browser.select(id: 'multiselect')
|
11
|
+
@widget = Domkey::View::WatirWidget.new(@object)
|
12
|
+
end
|
13
|
+
|
14
|
+
before :each do
|
15
|
+
goto_html("test.html")
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'initial value on the test page' do
|
19
|
+
@widget.value.should eql ["English", "Norwegian"]
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'set array of strings clears all. sets text items provided. value is array of visible texts' do
|
23
|
+
# texts are items visible to the user [text or label of select list option]
|
24
|
+
@widget.set ['Polish', 'Norwegian']
|
25
|
+
@widget.value.should eql ["Norwegian", "Polish"]
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'set false clears all. value is empty array' do
|
29
|
+
@widget.set false
|
30
|
+
@widget.value.should eql []
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'set empty array clears all. value is empty array' do
|
34
|
+
@widget.set []
|
35
|
+
@widget.value.should eql []
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'set string clears all. sets one text item. value is one item' do
|
39
|
+
@widget.set 'Polish'
|
40
|
+
@widget.value.should eql ["Polish"]
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'set by text' do
|
44
|
+
@widget.set text: 'Polish'
|
45
|
+
@widget.value.should eql ["Polish"]
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'set by array of texts' do
|
49
|
+
# client would not usually do this.
|
50
|
+
# Client would simply call set ['Polish', 'Norwegian']
|
51
|
+
# becuase text: qualifer is a default way of setting select list by visible text
|
52
|
+
@widget.set text: ['Polish', 'Norwegian']
|
53
|
+
@widget.value.should eql ["Norwegian", "Polish"]
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'set index by option position' do
|
57
|
+
@widget.set index: 1
|
58
|
+
@widget.value.should eql ['English']
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'set index array of option positions' do
|
62
|
+
@widget.set index: [0, 2]
|
63
|
+
@widget.value.should eql ["Danish", "Norwegian"]
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'set value attribute string' do
|
67
|
+
@widget.set value: '2'
|
68
|
+
@widget.value.should eql ['English']
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'set value attribute array of strings' do
|
72
|
+
@widget.set value: ['2', '1']
|
73
|
+
@widget.value.should eql ["Danish", "English"]
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'set by many qualifiers at once' do
|
77
|
+
@widget.set value: ['2', '1'],
|
78
|
+
text: 'Swedish',
|
79
|
+
index: 3
|
80
|
+
@widget.value.should eql ['Danish', 'English', 'Polish', 'Swedish']
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'options' do
|
84
|
+
@widget.options.should eql [{:text=>"Danish", :value=>"1"},
|
85
|
+
{:text=>"English", :value=>"2"},
|
86
|
+
{:text=>"Norwegian", :value=>"3"},
|
87
|
+
{:text=>"Polish", :value=>""},
|
88
|
+
{:text=>"Swedish", :value=>"Swedish"}]
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
context "Single" do
|
94
|
+
|
95
|
+
before :all do
|
96
|
+
object = Domkey.browser.select(id: 'fruit_list')
|
97
|
+
@widget = Domkey::View::WatirWidget.new(object)
|
98
|
+
end
|
99
|
+
|
100
|
+
before :each do
|
101
|
+
goto_html("test.html")
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'initial value on the test page visible text to the user' do
|
105
|
+
@widget.value.should eql ['Default']
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'set string selects visible text. value is visible text to the user' do
|
109
|
+
# option text
|
110
|
+
@widget.set 'Tomato'
|
111
|
+
@widget.value.should eql ['Tomato'] # not value attribute, visible text [text, label]
|
112
|
+
|
113
|
+
# option label attribute text
|
114
|
+
@widget.set 'Other'
|
115
|
+
@widget.value.should eql ['Other']
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'set array of text or label' do
|
119
|
+
@widget.set ['Other', 'Tomato'] #cycle on single select list
|
120
|
+
@widget.value.should eql ['Tomato'] # the last one set
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'set by array of text' do
|
124
|
+
@widget.set text: ['Other', 'Tomato']
|
125
|
+
@widget.value.should eql ['Tomato']
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'set false has no effect. value is selected item text' do
|
129
|
+
@widget.set false
|
130
|
+
@widget.value.should eql ['Default']
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'set empty array has no effect. value is selected item text' do
|
134
|
+
@widget.set []
|
135
|
+
@widget.value.should eql ['Default']
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'set index position' do
|
139
|
+
@widget.set index: 1
|
140
|
+
@widget.value.should eql ['Cucumber']
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'set index array' do
|
144
|
+
@widget.set index: [0, 2]
|
145
|
+
@widget.value.should eql ['Other'] # the last one wins
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'set value attribute string' do
|
149
|
+
@widget.set value: 'tomato'
|
150
|
+
@widget.value.should eql ['Tomato']
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'set value attribute array of strings' do
|
154
|
+
@widget.set value: ['tomato', 'gurken']
|
155
|
+
@widget.value.should eql ['Cucumber']
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'set by many qualifiers at once' do
|
159
|
+
@widget.set value: ['gurken'],
|
160
|
+
text: 'Tomato',
|
161
|
+
index: 2
|
162
|
+
@widget.value.should eql ['Other']
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'options' do
|
166
|
+
@widget.options.should eql [{:text=>"Tomato", :value=>"tomato"},
|
167
|
+
{:text=>"Cucumber", :value=>"gurken"},
|
168
|
+
{:text=>"Other", :value=>""},
|
169
|
+
{:text=>"Default", :value=>"Default"}]
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|