diff options
author | Robert Speicher <rspeicher@gmail.com> | 2012-08-29 02:21:50 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2012-08-29 10:44:34 -0400 |
commit | 2bdea8651fa3bd82418986ada84828c22d451405 (patch) | |
tree | 24207ec6492308da8cc1f4d1e7f1297cc9a09bb1 | |
parent | 9e7d77cece06e48ac0f44ee808976ec6dcbff81d (diff) | |
download | gitlab-ce-2bdea8651fa3bd82418986ada84828c22d451405.tar.gz |
Add is_within method for shoulda's EnsureLengthOf matcher
-rw-r--r-- | spec/support/matchers.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index 14a03870a6c..cb1dcba3dd8 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -67,3 +67,17 @@ module UrlAccess login_with(user) if user end end + +# Extend shoulda-matchers +module Shoulda::Matchers::ActiveModel + class EnsureLengthOfMatcher + # Shortcut for is_at_least and is_at_most + def is_within(range) + if range.exclude_end? + is_at_least(range.first) && is_at_most(range.last - 1) + else + is_at_least(range.first) && is_at_most(range.last) + end + end + end +end |