|
162 | 162 | end
|
163 | 163 |
|
164 | 164 | describe "Node#set" do
|
165 |
| - before do |
166 |
| - @session.visit("/cuprite/with_js") |
167 |
| - @session.find(:css, "#change_me").set("Hello!") |
168 |
| - end |
| 165 | + context "with_js" do |
| 166 | + before do |
| 167 | + @session.visit("/cuprite/with_js") |
| 168 | + @session.find(:css, "#change_me").set("Hello!") |
| 169 | + end |
169 | 170 |
|
170 |
| - it "fires the change event" do |
171 |
| - expect(@session.find(:css, "#changes").text).to eq("Hello!") |
172 |
| - end |
| 171 | + it "fires the change event" do |
| 172 | + expect(@session.find(:css, "#changes").text).to eq("Hello!") |
| 173 | + end |
173 | 174 |
|
174 |
| - it "fires the input event" do |
175 |
| - expect(@session.find(:css, "#changes_on_input").text).to eq("Hello!") |
176 |
| - end |
| 175 | + it "fires the input event" do |
| 176 | + expect(@session.find(:css, "#changes_on_input").text).to eq("Hello!") |
| 177 | + end |
177 | 178 |
|
178 |
| - it "accepts numbers in a maxlength field" do |
179 |
| - element = @session.find(:css, "#change_me_maxlength") |
180 |
| - element.set 100 |
181 |
| - expect(element.value).to eq("100") |
182 |
| - end |
| 179 | + it "accepts numbers in a maxlength field" do |
| 180 | + element = @session.find(:css, "#change_me_maxlength") |
| 181 | + element.set 100 |
| 182 | + expect(element.value).to eq("100") |
| 183 | + end |
183 | 184 |
|
184 |
| - it "accepts negatives in a number field" do |
185 |
| - element = @session.find(:css, "#change_me_number") |
186 |
| - element.set(-100) |
187 |
| - expect(element.value).to eq("-100") |
188 |
| - end |
| 185 | + it "accepts negatives in a number field" do |
| 186 | + element = @session.find(:css, "#change_me_number") |
| 187 | + element.set(-100) |
| 188 | + expect(element.value).to eq("-100") |
| 189 | + end |
189 | 190 |
|
190 |
| - it "fires the keydown event" do |
191 |
| - expect(@session.find(:css, "#changes_on_keydown").text).to eq("6") |
192 |
| - end |
| 191 | + it "fires the keydown event" do |
| 192 | + expect(@session.find(:css, "#changes_on_keydown").text).to eq("6") |
| 193 | + end |
193 | 194 |
|
194 |
| - it "fires the keyup event" do |
195 |
| - expect(@session.find(:css, "#changes_on_keyup").text).to eq("6") |
196 |
| - end |
| 195 | + it "fires the keyup event" do |
| 196 | + expect(@session.find(:css, "#changes_on_keyup").text).to eq("6") |
| 197 | + end |
197 | 198 |
|
198 |
| - it "fires the keypress event" do |
199 |
| - expect(@session.find(:css, "#changes_on_keypress").text).to eq("6") |
200 |
| - end |
| 199 | + it "fires the keypress event" do |
| 200 | + expect(@session.find(:css, "#changes_on_keypress").text).to eq("6") |
| 201 | + end |
201 | 202 |
|
202 |
| - it "fires the focus event" do |
203 |
| - expect(@session.find(:css, "#changes_on_focus").text).to eq("Focus") |
204 |
| - end |
| 203 | + it "fires the focus event" do |
| 204 | + expect(@session.find(:css, "#changes_on_focus").text).to eq("Focus") |
| 205 | + end |
205 | 206 |
|
206 |
| - it "fires the blur event" do |
207 |
| - expect(@session.find(:css, "#changes_on_blur").text).to eq("Blur") |
208 |
| - end |
| 207 | + it "fires the blur event" do |
| 208 | + expect(@session.find(:css, "#changes_on_blur").text).to eq("Blur") |
| 209 | + end |
209 | 210 |
|
210 |
| - it "fires the keydown event before the value is updated" do |
211 |
| - expect(@session.find(:css, "#value_on_keydown").text).to eq("Hello") |
212 |
| - end |
| 211 | + it "fires the keydown event before the value is updated" do |
| 212 | + expect(@session.find(:css, "#value_on_keydown").text).to eq("Hello") |
| 213 | + end |
213 | 214 |
|
214 |
| - it "fires the keyup event after the value is updated" do |
215 |
| - expect(@session.find(:css, "#value_on_keyup").text).to eq("Hello!") |
216 |
| - end |
| 215 | + it "fires the keyup event after the value is updated" do |
| 216 | + expect(@session.find(:css, "#value_on_keyup").text).to eq("Hello!") |
| 217 | + end |
217 | 218 |
|
218 |
| - it "clears the input before setting the new value" do |
219 |
| - element = @session.find(:css, "#change_me") |
220 |
| - element.set "" |
221 |
| - expect(element.value).to eq("") |
222 |
| - end |
| 219 | + it "clears the input before setting the new value" do |
| 220 | + element = @session.find(:css, "#change_me") |
| 221 | + element.set "" |
| 222 | + expect(element.value).to eq("") |
| 223 | + end |
223 | 224 |
|
224 |
| - it "supports special characters" do |
225 |
| - element = @session.find(:css, "#change_me") |
226 |
| - element.set "$52.00" |
227 |
| - expect(element.value).to eq("$52.00") |
228 |
| - end |
| 225 | + it "supports special characters" do |
| 226 | + element = @session.find(:css, "#change_me") |
| 227 | + element.set "$52.00" |
| 228 | + expect(element.value).to eq("$52.00") |
| 229 | + end |
229 | 230 |
|
230 |
| - it "attaches a file when passed a Pathname" do |
231 |
| - filename = Pathname.new("spec/tmp/a_test_pathname").expand_path |
232 |
| - File.write(filename, "text") |
| 231 | + it "attaches a file when passed a Pathname" do |
| 232 | + filename = Pathname.new("spec/tmp/a_test_pathname").expand_path |
| 233 | + File.write(filename, "text") |
| 234 | + |
| 235 | + element = @session.find(:css, "#change_me_file") |
| 236 | + element.set(filename) |
| 237 | + expect(element.value).to eq("C:\\fakepath\\a_test_pathname") |
| 238 | + ensure |
| 239 | + FileUtils.rm_f(filename) |
| 240 | + end |
233 | 241 |
|
234 |
| - element = @session.find(:css, "#change_me_file") |
235 |
| - element.set(filename) |
236 |
| - expect(element.value).to eq("C:\\fakepath\\a_test_pathname") |
237 |
| - ensure |
238 |
| - FileUtils.rm_f(filename) |
| 242 | + it "sets a value for a color input" do |
| 243 | + element = @session.find(:css, "#change_me_color") |
| 244 | + element.set("#ddeeff") |
| 245 | + expect(element.value).to eq("#ddeeff") |
| 246 | + end |
239 | 247 | end
|
240 | 248 |
|
241 |
| - it "sets a value for a color input" do |
242 |
| - element = @session.find(:css, "#change_me_color") |
243 |
| - element.set("#ddeeff") |
244 |
| - expect(element.value).to eq("#ddeeff") |
| 249 | + # The time inputs are loading SVG icons as data: urls. |
| 250 | + # This is causing other unrelated tests to break. |
| 251 | + # Keep the time inputs (And others with SVG icons) in their own file |
| 252 | + context "time_inputs" do |
| 253 | + before(:each) do |
| 254 | + @session.visit("/cuprite/time_inputs") |
| 255 | + end |
| 256 | + |
| 257 | + it "sets a value for a time input" do |
| 258 | + element = @session.find(:css, "#change_me_time") |
| 259 | + element.set("17:21") |
| 260 | + expect(element.value).to eq("17:21") |
| 261 | + end |
| 262 | + |
| 263 | + it "sets a value for a time input with a time object" do |
| 264 | + element = @session.find(:css, "#change_me_time") |
| 265 | + element.set(Time.new(2023, 9, 26, 17, 21)) |
| 266 | + expect(element.value).to eq("17:21") |
| 267 | + end |
| 268 | + |
| 269 | + it "sets a value for a time input with a date object" do |
| 270 | + element = @session.find(:css, "#change_me_time") |
| 271 | + element.set(Date.new(2023, 9, 26)) |
| 272 | + expect(element.value).to eq("00:00") |
| 273 | + end |
| 274 | + |
| 275 | + it "sets a value for a time input with a datetime object" do |
| 276 | + element = @session.find(:css, "#change_me_time") |
| 277 | + element.set(DateTime.new(2023, 9, 26, 17, 21)) |
| 278 | + expect(element.value).to eq("17:21") |
| 279 | + end |
| 280 | + |
| 281 | + it "sets a value for a date input" do |
| 282 | + element = @session.find(:css, "#change_me_date") |
| 283 | + element.set("2023-09-26") |
| 284 | + expect(element.value).to eq("2023-09-26") |
| 285 | + end |
| 286 | + |
| 287 | + it "sets a value for a date input with a date object" do |
| 288 | + element = @session.find(:css, "#change_me_date") |
| 289 | + element.set(Date.new(2023, 9, 26)) |
| 290 | + expect(element.value).to eq("2023-09-26") |
| 291 | + end |
| 292 | + |
| 293 | + it "sets a value for a date input with a time object" do |
| 294 | + element = @session.find(:css, "#change_me_date") |
| 295 | + element.set(Time.new(2023, 9, 26, 17, 21)) |
| 296 | + expect(element.value).to eq("2023-09-26") |
| 297 | + end |
| 298 | + |
| 299 | + it "sets a value for a date input with a datetime object" do |
| 300 | + element = @session.find(:css, "#change_me_date") |
| 301 | + element.set(DateTime.new(2023, 9, 26, 17, 21)) |
| 302 | + expect(element.value).to eq("2023-09-26") |
| 303 | + end |
| 304 | + |
| 305 | + it "sets a value for a month input" do |
| 306 | + element = @session.find(:css, "#change_me_month") |
| 307 | + element.set("2023-09") |
| 308 | + expect(element.value).to eq("2023-09") |
| 309 | + end |
| 310 | + |
| 311 | + it "sets a value for a month input with a date object" do |
| 312 | + element = @session.find(:css, "#change_me_month") |
| 313 | + element.set(Date.new(2023, 9, 26)) |
| 314 | + expect(element.value).to eq("2023-09") |
| 315 | + end |
| 316 | + |
| 317 | + it "sets a value for a month input with a time object" do |
| 318 | + element = @session.find(:css, "#change_me_month") |
| 319 | + element.set(Time.new(2023, 9, 26, 17, 21)) |
| 320 | + expect(element.value).to eq("2023-09") |
| 321 | + end |
| 322 | + |
| 323 | + it "sets a value for a month input with a datetime object" do |
| 324 | + element = @session.find(:css, "#change_me_month") |
| 325 | + element.set(DateTime.new(2023, 9, 26, 17, 21)) |
| 326 | + expect(element.value).to eq("2023-09") |
| 327 | + end |
| 328 | + |
| 329 | + |
| 330 | + it "sets a value for a week input" do |
| 331 | + element = @session.find(:css, "#change_me_week") |
| 332 | + element.set("2023-W39") |
| 333 | + expect(element.value).to eq("2023-W39") |
| 334 | + end |
| 335 | + |
| 336 | + it "sets a value for a week input with a date object" do |
| 337 | + element = @session.find(:css, "#change_me_week") |
| 338 | + element.set(Date.new(2023, 9, 26)) |
| 339 | + expect(element.value).to eq("2023-W39") |
| 340 | + end |
| 341 | + |
| 342 | + it "sets a value for a week input with a time object" do |
| 343 | + element = @session.find(:css, "#change_me_week") |
| 344 | + element.set(Time.new(2023, 9, 26, 17, 21)) |
| 345 | + expect(element.value).to eq("2023-W39") |
| 346 | + end |
| 347 | + |
| 348 | + it "sets a value for a week input with a datetime object" do |
| 349 | + element = @session.find(:css, "#change_me_week") |
| 350 | + element.set(DateTime.new(2023, 9, 26, 17, 21)) |
| 351 | + expect(element.value).to eq("2023-W39") |
| 352 | + end |
245 | 353 | end
|
246 | 354 | end
|
247 | 355 |
|
|
0 commit comments