capybara_error_intel 0.1.2 → 1.0.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 +12 -3
- data/capybara_error_intel.gemspec +1 -1
- data/lib/capybara_error_intel/dsl.rb +59 -13
- data/lib/capybara_error_intel/version.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: 5862341b63629cf16f8b3339b62789c905b61170
|
4
|
+
data.tar.gz: b9472f2a9161625dbea7f8596fa49dc074ba8108
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33d204d510b83490e5fff56da2b4018c79fb6f031ff8eedfe6195ec60b995b5a6672f6009a480df95d3497e063795fbe66e2fdfffd0cdc66f7e2a87597f833e8
|
7
|
+
data.tar.gz: 332f5782bf6eac411f4b6a01ff76159d8e97e0b89ef930809053113a5728a6b8c6a4170bb15a573658c2eb5f6f450b2cfc1a6796f51778a8ce6d5a8eb4aeb715
|
data/README.md
CHANGED
@@ -63,9 +63,18 @@ end
|
|
63
63
|
Note: currently this gem only supports the following Capybara built-in predicate
|
64
64
|
methods:
|
65
65
|
|
66
|
-
- `has_selector
|
67
|
-
- `has_text
|
68
|
-
- `has_title
|
66
|
+
- `has_selector?(*args)`
|
67
|
+
- `has_text?(*args)` (and `has_content?` alias)
|
68
|
+
- `has_title?(title, options={})`
|
69
|
+
- `has_css?(css, options={})`
|
70
|
+
- `has_button?(locator, options={})`
|
71
|
+
- `has_field?(locator, options={})`
|
72
|
+
- `has_xpath?(xpath, options={})`
|
73
|
+
- `has_checked_field?(locator, options={})`
|
74
|
+
- `has_unchecked_field?(locator, options={})`
|
75
|
+
- `has_select?(locator, options={})`
|
76
|
+
- `has_table?(locator, options={})`
|
77
|
+
|
69
78
|
|
70
79
|
It should be rather trivial to add more of them like `has_css` etc. I will try
|
71
80
|
to implement the rest in the near future but feel free to submit a pull
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.summary = %q{Provides Capybara's heuristic error messages for Page Objects}
|
13
13
|
spec.description = %q{Capybara provides excellent error messages for its
|
14
14
|
built in predicate methods: has_selector?, has_text?,
|
15
|
-
|
15
|
+
has_title? etc.. but when those are used from Page
|
16
16
|
Objects while exposing predicate methods from the
|
17
17
|
PageObjects themselves the error messages are lost
|
18
18
|
and all we get is "expected true, got false".
|
@@ -1,33 +1,79 @@
|
|
1
1
|
module CapybaraErrorIntel
|
2
2
|
module DSL
|
3
3
|
def has_selector?(*args)
|
4
|
-
matcher =
|
4
|
+
matcher = has_selector(*args)
|
5
5
|
match_or_error(matcher)
|
6
6
|
end
|
7
7
|
|
8
|
+
def has_css?(css, options={})
|
9
|
+
has_selector?(:css, css, options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def has_button?(locator, options={})
|
13
|
+
has_selector?(:button, locator, options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def has_field?(locator, options={})
|
17
|
+
has_selector?(:field, locator, options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def has_xpath?(xpath, options={})
|
21
|
+
has_selector?(:xpath, locator, options)
|
22
|
+
end
|
23
|
+
|
24
|
+
def has_checked_field?(locator, options={})
|
25
|
+
has_selector?(:field, locator, options.merge(:checked => true))
|
26
|
+
end
|
27
|
+
|
28
|
+
def has_unchecked_field?(locator, options={})
|
29
|
+
has_selector?(:field, locator, options.merge(:unchecked => true))
|
30
|
+
end
|
31
|
+
|
32
|
+
def has_select?(locator, options={})
|
33
|
+
has_selector?(:select, locator, options)
|
34
|
+
end
|
35
|
+
|
36
|
+
def has_table?(locator, options={})
|
37
|
+
has_selector?(:table, locator, options)
|
38
|
+
end
|
39
|
+
|
8
40
|
def has_text?(*args)
|
9
|
-
matcher =
|
41
|
+
matcher = has_text(*args)
|
10
42
|
match_or_error(matcher)
|
11
43
|
end
|
12
44
|
alias_method :has_content?, :has_text?
|
13
45
|
|
14
46
|
def has_title?(title, options = {})
|
15
|
-
matcher =
|
47
|
+
matcher = has_title(title, options)
|
16
48
|
match_or_error(matcher)
|
17
49
|
end
|
18
50
|
|
19
|
-
|
20
|
-
matcher.matches?(Capybara.current_session) || handle_failure(matcher)
|
21
|
-
end
|
51
|
+
private
|
22
52
|
|
23
|
-
|
24
|
-
|
53
|
+
def has_selector(*args)
|
54
|
+
Capybara::RSpecMatchers::HaveSelector.new(*args)
|
55
|
+
end
|
25
56
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
57
|
+
def has_text(*args)
|
58
|
+
Capybara::RSpecMatchers::HaveText.new(*args)
|
59
|
+
end
|
60
|
+
|
61
|
+
def has_title(title, options)
|
62
|
+
Capybara::RSpecMatchers::HaveTitle.new(title, options)
|
63
|
+
end
|
64
|
+
|
65
|
+
def match_or_error(matcher)
|
66
|
+
matcher.matches?(Capybara.current_session) || handle_failure(matcher)
|
67
|
+
end
|
68
|
+
|
69
|
+
def handle_failure(matcher)
|
70
|
+
message = matcher.failure_message
|
71
|
+
|
72
|
+
if matcher.respond_to?(:diffable?) && matcher.diffable?
|
73
|
+
RSpec::Expectations.fail_with message, matcher.expected, matcher.actual
|
74
|
+
else
|
75
|
+
RSpec::Expectations.fail_with message
|
76
|
+
end
|
30
77
|
end
|
31
|
-
end
|
32
78
|
end
|
33
79
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara_error_intel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Karter
|
@@ -171,7 +171,7 @@ dependencies:
|
|
171
171
|
description: |-
|
172
172
|
Capybara provides excellent error messages for its
|
173
173
|
built in predicate methods: has_selector?, has_text?,
|
174
|
-
|
174
|
+
has_title? etc.. but when those are used from Page
|
175
175
|
Objects while exposing predicate methods from the
|
176
176
|
PageObjects themselves the error messages are lost
|
177
177
|
and all we get is "expected true, got false".
|