capybara-select2 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -3
- data/lib/capybara-select2/version.rb +1 -1
- data/lib/capybara/select2.rb +21 -0
- metadata +2 -1
data/README.md
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
# Capybara::Select2
|
2
2
|
|
3
|
-
|
3
|
+
All this gem does is something very simple- allow you to trigger select2 dropdown to select the value you want. The original select doesn't with the javascript overrides, so this new helper method does only this thing.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem 'capybara-select2'
|
9
|
+
gem 'capybara-select2', group: :test
|
10
|
+
|
11
|
+
Or, add it into your test group
|
12
|
+
|
13
|
+
group :test do
|
14
|
+
gem 'capybara-select2'
|
15
|
+
...
|
16
|
+
end
|
10
17
|
|
11
18
|
And then execute:
|
12
19
|
|
@@ -16,9 +23,12 @@ Or install it yourself as:
|
|
16
23
|
|
17
24
|
$ gem install capybara-select2
|
18
25
|
|
26
|
+
The gem automatically hook itself into rspec helper using Rspec.configure.
|
27
|
+
|
19
28
|
## Usage
|
20
29
|
|
21
|
-
|
30
|
+
Just use this method inside your capybara test:
|
31
|
+
select2("Dropdown Text", from: "Label of the dropdown")
|
22
32
|
|
23
33
|
## Contributing
|
24
34
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Capybara
|
2
|
+
module Select2
|
3
|
+
def select2(value, options={})
|
4
|
+
raise "Must pass a hash containing 'from'" if not options.is_a?(Hash) or not options.has_key?(:from)
|
5
|
+
select_name = options[:from]
|
6
|
+
|
7
|
+
select2_container=find("label:contains(\"#{select_name}\")").find(:xpath, '..').find(".select2-container")
|
8
|
+
PP.pp(select2_container)
|
9
|
+
|
10
|
+
select2_container.find(".select2-choice").click
|
11
|
+
|
12
|
+
find(".select2-drop li:contains(\"#{value}\")").click
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
RSpec.configure do |c|
|
19
|
+
c.include Capybara::Select2
|
20
|
+
end
|
21
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-select2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- capybara-select2.gemspec
|
59
59
|
- lib/capybara-select2.rb
|
60
60
|
- lib/capybara-select2/version.rb
|
61
|
+
- lib/capybara/select2.rb
|
61
62
|
homepage: ''
|
62
63
|
licenses: []
|
63
64
|
post_install_message:
|