mache 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 912b56e289aa3e69473fd758575e2f43afe3818b
4
- data.tar.gz: abcf1936d0c0c3cf08c6c27a8148f7107333500b
3
+ metadata.gz: f2a6457504e07023cbe3e84e72ef455a22081ecd
4
+ data.tar.gz: cce7b3211712bfa08b179b9b9cd8f237eca299b3
5
5
  SHA512:
6
- metadata.gz: 0d6ad5456be773a9fe544700e8377227fd4bd50be9d22baca2d94fccd641c212a3c62189114a3de9b59a757eb1fd39852cc3a67230e288b790636cea1bac9ae3
7
- data.tar.gz: 8ad576449372f1966b1fcba9e6db5753cb6d1b41c403307496041958270451b3de0b6f621a9b2c8dfbdbbe1945e99d4416a7ed3f4449cd154a42d5453311f3da
6
+ metadata.gz: 2ca5d81a94c1c56716d9e9411abf47bac750198dd07950d049bbcb4612dcf6ded9e96c3b3eddcb91f428be49846772d179e37074e1aeb8956b880f0dd8fb5e3c
7
+ data.tar.gz: 15b0571b00474011618204d7eb7e82fcdbac3d06ccda60f0ea55ca39dc7a05c3206a6e1fd020a31a1dc6eb19ff75df8919727e43f350cd7d4f0fbb7b7dfe906b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.1
4
+
5
+ - Fix a bug in the flash helper matchers.
6
+
3
7
  ## 2.1.0
4
8
 
5
9
  - Add flash and routing helpers.
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.has_notice_message?("Welcome to the app")
188
- page.has_alert_message?("A horrible error occurred")
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 :flash, selector
15
+ element(:flash, selector)
14
16
  end
15
17
  end
16
18
 
17
- # rubocop:disable Style/PredicateName
18
- def has_notice_message?(text)
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
- css_class.include?("notice") && flash.text =~ /\s*#{text}\s*/
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
- css_class = flash[:class] || ""
25
- css_class.include?("error") && flash.text =~ /\s*#{text}\s*/
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
@@ -1,3 +1,3 @@
1
1
  module Mache
2
- VERSION = "2.1.0".freeze
2
+ VERSION = "2.1.1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mache
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Bassett