capybara-select2 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/capybara-select2.rb +21 -1
- data/lib/capybara-select2/version.rb +1 -1
- data/lib/capybara/select2.rb +1 -21
- metadata +1 -1
data/lib/capybara-select2.rb
CHANGED
@@ -1,2 +1,22 @@
|
|
1
1
|
require "capybara-select2/version"
|
2
|
-
|
2
|
+
|
3
|
+
module Capybara
|
4
|
+
module Select2
|
5
|
+
def select2(value, options={})
|
6
|
+
raise "Must pass a hash containing 'from'" if not options.is_a?(Hash) or not options.has_key?(:from)
|
7
|
+
select_name = options[:from]
|
8
|
+
|
9
|
+
select2_container=find("label:contains(\"#{select_name}\")").find(:xpath, '..').find(".select2-container")
|
10
|
+
PP.pp(select2_container)
|
11
|
+
|
12
|
+
select2_container.find(".select2-choice").click
|
13
|
+
|
14
|
+
find(".select2-drop li:contains(\"#{value}\")").click
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
RSpec.configure do |c|
|
21
|
+
c.include Capybara::Select2
|
22
|
+
end
|
data/lib/capybara/select2.rb
CHANGED
@@ -1,21 +1 @@
|
|
1
|
-
|
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
|
-
|
1
|
+
require '../capybara-select2'
|