capybara-select-2 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -2
- data/lib/capybara_select2.rb +11 -0
- data/lib/capybara_select2/config.rb +15 -0
- data/lib/capybara_select2/helpers.rb +21 -15
- data/lib/capybara_select2/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9678aa226fd30f77d126dbc9910dbfb52c6c8d38
|
4
|
+
data.tar.gz: c204deba3c13b6e1e23c71d21515f9474b4e09f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57acf0411c48a5a2a82616d8f944cb17e0b49b11088068430f209c18764b9d2bf17cbfc65fcb55ed4f1080052b57af94e881c664ff8823cd1f66cc9becb4e418
|
7
|
+
data.tar.gz: 6856a1f8b811ae3a4febadac8979d36facf4a32768485fb38b902b0ac2947699c366f7ed32898f5338757d365f9b77b31e394cb42127adb8e26e7d5a04856e45
|
data/README.md
CHANGED
@@ -18,7 +18,9 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install capybara-select-2
|
20
20
|
|
21
|
-
|
21
|
+
[Note] In the projects which use RSpec or Cucumber `select2` helper should be loaded automatically
|
22
|
+
|
23
|
+
### Manual installation with Rspec
|
22
24
|
|
23
25
|
In your spec_helper.rb
|
24
26
|
|
@@ -28,7 +30,7 @@ RSpec.configure do |config|
|
|
28
30
|
end
|
29
31
|
```
|
30
32
|
|
31
|
-
### Cucumber
|
33
|
+
### Manual installation with Cucumber
|
32
34
|
|
33
35
|
In your env.rb
|
34
36
|
|
@@ -36,6 +38,20 @@ In your env.rb
|
|
36
38
|
World CapybaraSelect2
|
37
39
|
```
|
38
40
|
|
41
|
+
## Configuration
|
42
|
+
|
43
|
+
CapybaraSelect2 expects select2 version 4 by default. If you are using version 3 or 2 please specify it in your spec helper
|
44
|
+
|
45
|
+
```
|
46
|
+
CapybaraSelect2::Config.select2_version = 3
|
47
|
+
|
48
|
+
# or
|
49
|
+
|
50
|
+
CapybaraSelect2.configure do |config|
|
51
|
+
config.select2_version = 3
|
52
|
+
end
|
53
|
+
```
|
54
|
+
|
39
55
|
## Usage
|
40
56
|
|
41
57
|
### Select from a node containing select2 control
|
data/lib/capybara_select2.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
require "capybara_select2/version"
|
2
2
|
require 'capybara_select2/helpers'
|
3
|
+
require 'capybara_select2/config'
|
3
4
|
|
4
5
|
module CapybaraSelect2
|
5
6
|
include Helpers
|
6
7
|
end
|
8
|
+
|
9
|
+
if defined?(RSpec)
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.include CapybaraSelect2
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
if respond_to?(:World)
|
16
|
+
World(CapybaraSelect2)
|
17
|
+
end
|
@@ -1,21 +1,27 @@
|
|
1
1
|
module CapybaraSelect2
|
2
2
|
module Helpers
|
3
3
|
def select2(value, options = {})
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
".select2-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
4
|
+
version = Config.select2_version.to_s
|
5
|
+
|
6
|
+
open_select = {
|
7
|
+
'2' => ".select2-choice, .select2-search-field",
|
8
|
+
'3' => ".select2-choice, .select2-search-field",
|
9
|
+
'4' => ".select2-selection"
|
10
|
+
}[version]
|
11
|
+
|
12
|
+
search_input = {
|
13
|
+
'2' => ".select2-dropdown-open input.select2-focused",
|
14
|
+
'3' => ".select2-dropdown-open input.select2-input",
|
15
|
+
'4' => (
|
16
|
+
".select2-container--focus input.select2-search__field," + # single
|
17
|
+
".select2-container--open input.select2-search__field") # multi
|
18
|
+
}[version]
|
19
|
+
|
20
|
+
option = {
|
21
|
+
'2' => ".select2-container-active .select2-result",
|
22
|
+
'3' => ".select2-drop-active .select2-result",
|
23
|
+
'4' => ".select2-results .select2-results__option"
|
24
|
+
}[version]
|
19
25
|
|
20
26
|
container = if options[:xpath]
|
21
27
|
find(:xpath, options[:xpath])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-select-2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dzmitry Kavalionak
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- capybara_select2.gemspec
|
143
143
|
- lib/capybara-select-2.rb
|
144
144
|
- lib/capybara_select2.rb
|
145
|
+
- lib/capybara_select2/config.rb
|
145
146
|
- lib/capybara_select2/helpers.rb
|
146
147
|
- lib/capybara_select2/version.rb
|
147
148
|
homepage: https://github.com/Hirurg103/capybara_select2
|