selectivity-rails 0.0.7 → 0.0.8
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/README.md +3 -2
- data/lib/selectivity/rails/version.rb +1 -1
- data/lib/selectivity/rspec.rb +31 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4461c4f15d732317f7c29bfe4a3d662145fee35
|
4
|
+
data.tar.gz: 4381055dc91b1f0d98e308dfe2caa4eaab938acd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e867c641b4750b28e8f06ed2ba3bf7ee0b7a3499d8f5fc56d716dbe97989fea3456b7aa930d694b6589bdce00bf49a843a358bd7ddbaffaf5fbdb4c2e46e41d2
|
7
|
+
data.tar.gz: 4738e0bafd7ce4343c6e8cc64876c85132e0b4a8502e060007e46b6d5337e551ce29ef0ab6de333c9e6ac3dbffe7d1b4f6552ac9b223b2c30da72e68d1508007
|
data/README.md
CHANGED
@@ -108,9 +108,10 @@ selectivity_select('Poland', from: '#country')
|
|
108
108
|
To handle multiple select:
|
109
109
|
|
110
110
|
```ruby
|
111
|
-
selectivity_select('Netherlands', from: '#countries')
|
112
|
-
|
111
|
+
selectivity_select('Netherlands', 'Russia', from: '#countries')
|
112
|
+
# or, by single value:
|
113
113
|
selectivity_select('Russia', from: '#countries')
|
114
|
+
|
114
115
|
selectivity_unselect('Russia', from: '#countries')
|
115
116
|
```
|
116
117
|
|
data/lib/selectivity/rspec.rb
CHANGED
@@ -2,39 +2,54 @@ module Selectivity
|
|
2
2
|
module Rspec
|
3
3
|
module FeatureHelpers
|
4
4
|
|
5
|
-
def selectivity_select(value,
|
6
|
-
|
5
|
+
def selectivity_select(value, *args)
|
6
|
+
options = args.extract_options!
|
7
7
|
|
8
|
-
|
8
|
+
fail('Selectivity input not set!') unless options.has_key?(:from)
|
9
9
|
|
10
|
-
|
10
|
+
from = options.delete(:from)
|
11
|
+
input = find(:div, from, options)
|
12
|
+
items = multiselect?(input) ? args.unshift(value).uniq : [value]
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
page.evaluate_script("$('div.selectivity-result-item:contains(#{value})').trigger('click')")
|
15
|
-
end
|
14
|
+
items.each do |item|
|
15
|
+
select(input, item)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def selectivity_unselect(value,
|
19
|
+
def selectivity_unselect(value, *args)
|
20
|
+
options = args.extract_options!
|
21
|
+
|
20
22
|
fail('Selectivity input not set!') unless options.has_key?(:from)
|
21
23
|
|
22
|
-
from
|
23
|
-
|
24
|
+
from = options.delete(:from)
|
25
|
+
input = find(:div, from, options)
|
26
|
+
items = multiselect?(input) ? args.unshift(value).uniq : [value]
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
28
|
+
items.each do |item|
|
29
|
+
if multiselect?(input)
|
30
|
+
unselect_multiple(input, item)
|
31
|
+
else
|
32
|
+
unselect_single(input)
|
33
|
+
end
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
32
37
|
private
|
33
38
|
|
34
|
-
def
|
39
|
+
def multiselect?(input)
|
35
40
|
input.first('.selectivity-multiple-input-container').present?
|
36
41
|
end
|
37
42
|
|
43
|
+
def select(input, item)
|
44
|
+
input.click
|
45
|
+
|
46
|
+
within 'div.selectivity-dropdown' do
|
47
|
+
if (find(:xpath, "//div[@class='selectivity-result-item'][contains(text(), '#{item}')]")).visible?
|
48
|
+
page.evaluate_script("$('div.selectivity-result-item:contains(#{item})').trigger('click')")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
38
53
|
def unselect_single(input)
|
39
54
|
input.first('.selectivity-single-selected-item-remove').click
|
40
55
|
end
|