summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2017-02-09 20:21:31 -0500
committerRobert Speicher <rspeicher@gmail.com>2017-02-09 20:23:41 -0500
commit0d9cce410dd146e512dc84fdb39bff13929a1362 (patch)
tree213a54c9f8b365d5e673c9e89cfb29f63893e234 /spec/support
parente355d8fe287002df0948033a19db9caaf8174555 (diff)
downloadgitlab-ce-0d9cce410dd146e512dc84fdb39bff13929a1362.tar.gz
Remove a transient failure from spec/requests/api/groups_spec.rbrs-issue-27974
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/matchers/satisfy_matchers.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/support/matchers/satisfy_matchers.rb b/spec/support/matchers/satisfy_matchers.rb
new file mode 100644
index 00000000000..585915bac93
--- /dev/null
+++ b/spec/support/matchers/satisfy_matchers.rb
@@ -0,0 +1,19 @@
+# These matchers are a syntactic hack to provide more readable expectations for
+# an Enumerable object.
+#
+# They take advantage of the `all?`, `none?`, and `one?` methods, and the fact
+# that RSpec provides a `be_something` matcher for all predicates.
+#
+# Example:
+#
+# # Ensure exactly one object in an Array satisfies a condition
+# expect(users.one? { |u| u.admin? }).to eq true
+#
+# # The same thing, but using the `be_one` matcher
+# expect(users).to be_one { |u| u.admin? }
+#
+# # The same thing again, but using `satisfy_one` for improved readability
+# expect(users).to satisfy_one { |u| u.admin? }
+RSpec::Matchers.alias_matcher :satisfy_all, :be_all
+RSpec::Matchers.alias_matcher :satisfy_none, :be_none
+RSpec::Matchers.alias_matcher :satisfy_one, :be_one