@@ -89,24 +89,24 @@ module Ferrum
89
89
end
90
90
91
91
it "returns texts of selected options" do
92
- expect ( browser . at_xpath ( "//*[@id='form_region']" ) . selected ) . to eq ( [ "Norway" ] )
92
+ expect ( browser . at_xpath ( "//*[@id='form_region']" ) . selected . map ( & :text ) ) . to eq ( [ "Norway" ] )
93
93
end
94
94
95
95
context "when options exists but no selected option" do
96
96
it "returns first option text as default value" do
97
- expect ( browser . at_xpath ( "//*[@id='form_title']" ) . selected ) . to eq ( [ "Mrs" ] )
97
+ expect ( browser . at_xpath ( "//*[@id='form_title']" ) . selected . map ( & :text ) ) . to eq ( [ "Mrs" ] )
98
98
end
99
99
end
100
100
101
101
context "when no selected options" do
102
102
it "returns empty array" do
103
- expect ( browser . at_xpath ( "//*[@id='form_tendency']" ) . selected ) . to eq ( [ ] )
103
+ expect ( browser . at_xpath ( "//*[@id='form_tendency']" ) . selected . map ( & :text ) ) . to eq ( [ ] )
104
104
end
105
105
end
106
106
107
107
context "when selector is not <select>" do
108
108
it "raises JavaScriptError with proper message" do
109
- expect { browser . at_xpath ( "//*[@id='customer_name']" ) . selected }
109
+ expect { browser . at_xpath ( "//*[@id='customer_name']" ) . selected . map ( & :text ) }
110
110
. to raise_exception ( Ferrum ::JavaScriptError , /Element is not a <select> element/ )
111
111
end
112
112
end
@@ -118,13 +118,13 @@ module Ferrum
118
118
end
119
119
120
120
it "picks option in select by match string argument" do
121
- expect ( browser . at_xpath ( "//*[@id='form_title']" ) . select ( "Miss" ) . selected ) . to eq ( [ "Miss" ] )
121
+ expect ( browser . at_xpath ( "//*[@id='form_title']" ) . select ( "Miss" ) . selected . map ( & :text ) ) . to eq ( [ "Miss" ] )
122
122
end
123
123
124
124
shared_examples "clears selected options with no exception" do |options |
125
125
it "clears selected options with no exception" do
126
- expect ( browser . at_xpath ( "//*[@id='form_title']" ) . selected ) . to eq ( [ "Mrs" ] )
127
- expect ( browser . at_xpath ( "//*[@id='form_title']" ) . select ( options ) . selected ) . to eq ( [ ] )
126
+ expect ( browser . at_xpath ( "//*[@id='form_title']" ) . selected . map ( & :text ) ) . to eq ( [ "Mrs" ] )
127
+ expect ( browser . at_xpath ( "//*[@id='form_title']" ) . select ( options ) . selected . map ( & :text ) ) . to eq ( [ ] )
128
128
end
129
129
end
130
130
@@ -142,18 +142,20 @@ module Ferrum
142
142
143
143
context "when one of option with provided texts does not exist" do
144
144
it "picks only existed options with no exception" do
145
- expect ( browser . at_xpath ( "//*[@id='form_title']" ) . selected ) . to eq ( [ "Mrs" ] )
146
- expect ( browser . at_xpath ( "//*[@id='form_title']" ) . select ( %w[ Mrs SQL ] ) . selected ) . to eq ( [ "Mrs" ] )
145
+ expect ( browser . at_xpath ( "//*[@id='form_title']" ) . selected . map ( & :text ) ) . to eq ( [ "Mrs" ] )
146
+ expect ( browser . at_xpath ( "//*[@id='form_title']" ) . select ( %w[ Mrs SQL ] ) . selected . map ( & :text ) ) . to eq ( [ "Mrs" ] )
147
147
end
148
148
end
149
149
150
150
context "when select has multiple property" do
151
151
it "picks options in select by match arguments as array" do
152
- expect ( browser . at_xpath ( "//*[@id='form_languages']" ) . select ( %w[ SQL Ruby ] ) . selected ) . to eq ( %w[ Ruby SQL ] )
152
+ expect ( browser . at_xpath ( "//*[@id='form_languages']" ) . select ( %w[ SQL Ruby ] ) . selected . map ( &:text ) )
153
+ . to eq ( %w[ Ruby SQL ] )
153
154
end
154
155
155
156
it "picks options in select by match arguments as string" do
156
- expect ( browser . at_xpath ( "//*[@id='form_languages']" ) . select ( "SQL, Ruby" ) . selected ) . to eq ( %w[ Ruby SQL ] )
157
+ expect ( browser . at_xpath ( "//*[@id='form_languages']" ) . select ( "SQL, Ruby" ) . selected . map ( &:text ) )
158
+ . to eq ( %w[ Ruby SQL ] )
157
159
end
158
160
end
159
161
@@ -166,7 +168,7 @@ module Ferrum
166
168
167
169
context "when provided texts of disabled option" do
168
170
it "picks disabled option with no exception" do
169
- expect ( browser . at_xpath ( "//*[@id='form_title']" ) . select ( [ "Other" ] ) . selected ) . to eq ( [ "Other" ] )
171
+ expect ( browser . at_xpath ( "//*[@id='form_title']" ) . select ( [ "Other" ] ) . selected . map ( & :text ) ) . to eq ( [ "Other" ] )
170
172
end
171
173
end
172
174
end
0 commit comments