|
22 | 22 | module Selenium
|
23 | 23 | module WebDriver
|
24 | 24 | describe Interactions do
|
25 |
| - it 'creates a new key input' do |
26 |
| - expect(Interactions.key(:name)).to be_a(Interactions::KeyInput) |
| 25 | + describe '#key' do |
| 26 | + it 'creates a new key input with provided name' do |
| 27 | + device = Interactions.key(:name) |
| 28 | + |
| 29 | + expect(device).to be_a(Interactions::KeyInput) |
| 30 | + expect(device.name).to eq(:name) |
| 31 | + end |
| 32 | + |
| 33 | + it 'sets name to a random UUID if no name is provided' do |
| 34 | + allow(SecureRandom).to receive(:uuid).and_return(:id) |
| 35 | + |
| 36 | + device = Interactions.key |
| 37 | + |
| 38 | + expect(device).to be_a(Interactions::KeyInput) |
| 39 | + expect(device.name).to eq(:id) |
| 40 | + end |
27 | 41 | end
|
28 | 42 |
|
29 |
| - it 'creates a new pointer input' do |
30 |
| - expect(Interactions.pointer(:mouse)).to be_a(Interactions::PointerInput) |
| 43 | + describe '#pointer' do |
| 44 | + it 'creates a new pointer input with a provided name' do |
| 45 | + device = Interactions.pointer(:mouse, name: :name) |
| 46 | + |
| 47 | + expect(device).to be_a(Interactions::PointerInput) |
| 48 | + expect(device.name).to eq(:name) |
| 49 | + end |
| 50 | + |
| 51 | + it 'sets name to a random UUID if no name is provided' do |
| 52 | + allow(SecureRandom).to receive(:uuid).and_return(:id) |
| 53 | + |
| 54 | + device = Interactions.pointer(:mouse) |
| 55 | + |
| 56 | + expect(device).to be_a(Interactions::PointerInput) |
| 57 | + expect(device.name).to eq(:id) |
| 58 | + end |
31 | 59 | end
|
32 | 60 |
|
33 |
| - it 'creates a new none input' do |
34 |
| - expect(Interactions.none).to be_a(Interactions::NoneInput) |
| 61 | + describe '#none' do |
| 62 | + it 'creates a new pointer input with a provided name' do |
| 63 | + device = Interactions.none(:name) |
| 64 | + |
| 65 | + expect(device).to be_a(Interactions::NoneInput) |
| 66 | + expect(device.name).to eq(:name) |
| 67 | + end |
| 68 | + |
| 69 | + it 'sets name to a random UUID if no name is provided' do |
| 70 | + allow(SecureRandom).to receive(:uuid).and_return(:id) |
| 71 | + |
| 72 | + device = Interactions.none |
| 73 | + |
| 74 | + expect(device).to be_a(Interactions::NoneInput) |
| 75 | + expect(device.name).to eq(:id) |
| 76 | + end |
35 | 77 | end
|
36 | 78 | end
|
37 | 79 | end # WebDriver
|
|
0 commit comments