wildcard_finders 0.1.1 → 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/CHANGELOG.md +5 -0
- data/Gemfile +0 -2
- data/VERSION +1 -1
- data/lib/wildcard_finders/finders.rb +21 -12
- data/lib/wildcard_finders/matchers.rb +10 -14
- data/spec/wildcard_finders/finders_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08e9bfbc82ce9fecd8da133569bf329caba7730d
|
4
|
+
data.tar.gz: c6b99935e3fd5842737e3b54f10bb17513b946e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92a1eb85521d0b6e6781cbcd6cff8c3ff188821c0c982312ef0c452382bbfdbb4213344f83080a743b1d32337053505d70edc3e758339f7660f96ffc8790023d
|
7
|
+
data.tar.gz: 1cdf1dc1497902fbf05432fd4f88f64bb5f6d1e15254ccb41406594e5f8797d8898f94caaeeb76cb42c357191f8ae2a1c3194ee2f9bce5c626c6dc3fc2747e0f
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -6,18 +6,31 @@ module WildcardFinders
|
|
6
6
|
METHODS = []
|
7
7
|
|
8
8
|
# not to add METHODS
|
9
|
+
# FIXME: opts is not used. what was that?
|
9
10
|
def find_tag_like(tag, matcher = nil, opts = {}, &block)
|
10
11
|
if matcher.is_a?(Hash) && matcher.values.all? {|v| v.is_a?(String) }
|
11
12
|
find_exactly(tag, matcher)
|
12
13
|
else
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
wait_method = respond_to?(:synchronize) ? :synchronize : :wait_until
|
15
|
+
|
16
|
+
results = []
|
17
|
+
__send__(wait_method) do
|
18
|
+
results = all(tag).select do |element|
|
19
|
+
if matcher.is_a?(Hash)
|
20
|
+
hash_from_element = matcher.keys.each_with_object({}) {|key, h| h[key] = element[key] }
|
21
|
+
WildcardMatchers.wildcard_match?(hash_from_element, matcher)
|
22
|
+
else
|
23
|
+
WildcardMatchers.wildcard_match?(element, block || matcher)
|
24
|
+
end
|
19
25
|
end
|
20
|
-
end
|
26
|
+
end
|
27
|
+
|
28
|
+
if results.empty?
|
29
|
+
raise Capybara::ElementNotFound, "no <#{tag}> to match #{matcher}"
|
30
|
+
else
|
31
|
+
# not compatible for capybara 2.0
|
32
|
+
results.first
|
33
|
+
end
|
21
34
|
end
|
22
35
|
end
|
23
36
|
|
@@ -37,11 +50,7 @@ module WildcardFinders
|
|
37
50
|
x.descendant(tag.to_sym)[attr_matcher.inject(&:&)]
|
38
51
|
end
|
39
52
|
|
40
|
-
|
41
|
-
find(:xpath, xpath)
|
42
|
-
rescue Capybara::ElementNotFound
|
43
|
-
nil
|
44
|
-
end
|
53
|
+
find(:xpath, xpath)
|
45
54
|
end
|
46
55
|
|
47
56
|
def self.method_added(name)
|
@@ -19,25 +19,21 @@ module WildcardFinders
|
|
19
19
|
rspec_no_matcher_method_without_block = method.to_s.sub("find", "have_no") + "_without_block"
|
20
20
|
|
21
21
|
define_method(matcher_method) do |*args, &block|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
begin
|
23
|
+
__send__(method, *args, &block)
|
24
|
+
true
|
25
|
+
rescue ::Capybara::ElementNotFound
|
26
|
+
false
|
27
27
|
end
|
28
|
-
|
29
|
-
true
|
30
28
|
end
|
31
29
|
|
32
30
|
define_method(no_matcher_method) do |*args, &block|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
begin
|
32
|
+
__send__(method, *args, &block)
|
33
|
+
false
|
34
|
+
rescue ::Capybara::ElementNotFound
|
35
|
+
true
|
38
36
|
end
|
39
|
-
|
40
|
-
true
|
41
37
|
end
|
42
38
|
|
43
39
|
RSpec::Matchers.define(rspec_matcher_method_without_block) do |expected|
|
@@ -71,7 +71,7 @@ describe WildcardFinders::Finders do
|
|
71
71
|
with_them do
|
72
72
|
it "returns nil" do
|
73
73
|
visit "/a"
|
74
|
-
page.find_anchor_like(attr => value).
|
74
|
+
expect { page.find_anchor_like(attr => value) }.to raise_exception(Capybara::ElementNotFound)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wildcard_finders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- okitan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|