Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-07-22 05:09:58 +0300
committerRobert Speicher <rspeicher@gmail.com>2015-07-22 07:01:17 +0300
commit0d5cf111f3070994c0e80ef764d1bd4b9e4936b1 (patch)
treef435de3cf95481da997dece63f386fcfb7e90b70 /spec/support/matchers
parentff8811c40b33a3a98203478925810035fffe7094 (diff)
Move custom matchers to their own files under spec/support/matchers
Diffstat (limited to 'spec/support/matchers')
-rw-r--r--spec/support/matchers/include_module.rb13
-rw-r--r--spec/support/matchers/is_within.rb9
2 files changed, 22 insertions, 0 deletions
diff --git a/spec/support/matchers/include_module.rb b/spec/support/matchers/include_module.rb
new file mode 100644
index 00000000000..0a78af1e90e
--- /dev/null
+++ b/spec/support/matchers/include_module.rb
@@ -0,0 +1,13 @@
+RSpec::Matchers.define :include_module do |expected|
+ match do
+ described_class.included_modules.include?(expected)
+ end
+
+ description do
+ "includes the #{expected} module"
+ end
+
+ failure_message do
+ "expected #{described_class} to include the #{expected} module"
+ end
+end
diff --git a/spec/support/matchers/is_within.rb b/spec/support/matchers/is_within.rb
new file mode 100644
index 00000000000..0c35fc7e899
--- /dev/null
+++ b/spec/support/matchers/is_within.rb
@@ -0,0 +1,9 @@
+# Extend shoulda-matchers
+module Shoulda::Matchers::ActiveModel
+ class ValidateLengthOfMatcher
+ # Shortcut for is_at_least and is_at_most
+ def is_within(range)
+ is_at_least(range.min) && is_at_most(range.max)
+ end
+ end
+end