mache 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +11 -2
- data/lib/mache/helpers/rails/flash.rb +41 -7
- data/lib/mache/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2a6457504e07023cbe3e84e72ef455a22081ecd
|
4
|
+
data.tar.gz: cce7b3211712bfa08b179b9b9cd8f237eca299b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ca5d81a94c1c56716d9e9411abf47bac750198dd07950d049bbcb4612dcf6ded9e96c3b3eddcb91f428be49846772d179e37074e1aeb8956b880f0dd8fb5e3c
|
7
|
+
data.tar.gz: 15b0571b00474011618204d7eb7e82fcdbac3d06ccda60f0ea55ca39dc7a05c3206a6e1fd020a31a1dc6eb19ff75df8919727e43f350cd7d4f0fbb7b7dfe906b
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -184,8 +184,17 @@ end
|
|
184
184
|
Then you can query the flash on your page object:
|
185
185
|
|
186
186
|
```ruby
|
187
|
-
page.
|
188
|
-
page.
|
187
|
+
page.has_message?(:success, "lorem ipsum")
|
188
|
+
page.has_message?(:success, /lorem ipsum/)
|
189
|
+
```
|
190
|
+
|
191
|
+
There are even convenience matchers for the common types of flash messages:
|
192
|
+
|
193
|
+
```ruby
|
194
|
+
page.has_success_message?("lorem ipsum")
|
195
|
+
page.has_notice_message?("lorem ipsum")
|
196
|
+
page.has_alert_message?("lorem ipsum")
|
197
|
+
page.has_error_message?("lorem ipsum")
|
189
198
|
```
|
190
199
|
|
191
200
|
#### Routes
|
@@ -3,6 +3,8 @@ module Mache
|
|
3
3
|
module Rails
|
4
4
|
# The {Flash} module can be Included into page object classes that support
|
5
5
|
# flash behaviour.
|
6
|
+
#
|
7
|
+
# rubocop:disable Style/PredicateName
|
6
8
|
module Flash
|
7
9
|
def self.included(base)
|
8
10
|
base.extend(ClassMethods)
|
@@ -10,22 +12,54 @@ module Mache
|
|
10
12
|
|
11
13
|
module ClassMethods # :nodoc:
|
12
14
|
def flash(selector)
|
13
|
-
element
|
15
|
+
element(:flash, selector)
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
17
|
-
#
|
18
|
-
|
19
|
+
# Tests whether the page has a flash message.
|
20
|
+
#
|
21
|
+
# @param [String, Symbol] type a flash message type
|
22
|
+
# @param [Regexp, String] text a value to match
|
23
|
+
# @return `true` if the page has a matching message, `false` otherwise
|
24
|
+
def has_message?(type, text)
|
19
25
|
css_class = flash[:class] || ""
|
20
|
-
|
26
|
+
regexp = text.is_a?(String) ? /\A#{Regexp.escape(text)}\Z/ : text
|
27
|
+
css_class.include?(type.to_s) && flash.text.strip =~ regexp
|
28
|
+
end
|
29
|
+
|
30
|
+
# Tests whether the page has a success message.
|
31
|
+
#
|
32
|
+
# @param [Regexp, String] text a value to match
|
33
|
+
# @return `true` if the page has a matching message, `false` otherwise
|
34
|
+
def has_success_message?(text)
|
35
|
+
has_message?(:success, text)
|
21
36
|
end
|
22
37
|
|
38
|
+
# Tests whether the page has a notice message.
|
39
|
+
#
|
40
|
+
# @param [Regexp, String] text a value to match
|
41
|
+
# @return `true` if the page has a matching message, `false` otherwise
|
42
|
+
def has_notice_message?(text)
|
43
|
+
has_message?(:notice, text)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Tests whether the page has an alert message.
|
47
|
+
#
|
48
|
+
# @param [Regexp, String] text a value to match
|
49
|
+
# @return `true` if the page has a matching message, `false` otherwise
|
23
50
|
def has_alert_message?(text)
|
24
|
-
|
25
|
-
|
51
|
+
has_message?(:alert, text)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Tests whether the page has an error message.
|
55
|
+
#
|
56
|
+
# @param [Regexp, String] text a value to match
|
57
|
+
# @return `true` if the page has a matching message, `false` otherwise
|
58
|
+
def has_error_message?(text)
|
59
|
+
has_message?(:error, text)
|
26
60
|
end
|
27
|
-
# rubocop:enable Style/PredicateName
|
28
61
|
end
|
62
|
+
# rubocop:enable Style/PredicateName
|
29
63
|
end
|
30
64
|
end
|
31
65
|
end
|
data/lib/mache/version.rb
CHANGED