Class: Shoulda::Matchers::ActiveRecord::HaveSecureTokenMatcher
- Inherits:
-
Object
- Object
- Shoulda::Matchers::ActiveRecord::HaveSecureTokenMatcher
- Defined in:
- lib/shoulda/matchers/active_record/have_secure_token_matcher.rb
Instance Attribute Summary collapse
-
#token_attribute ⇒ Object
readonly
Returns the value of attribute token_attribute.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
- #ignoring_check_for_db_index ⇒ Object
-
#initialize(token_attribute) ⇒ HaveSecureTokenMatcher
constructor
A new instance of HaveSecureTokenMatcher.
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(token_attribute) ⇒ HaveSecureTokenMatcher
Returns a new instance of HaveSecureTokenMatcher.
55 56 57 58 |
# File 'lib/shoulda/matchers/active_record/have_secure_token_matcher.rb', line 55 def initialize(token_attribute) @token_attribute = token_attribute = { ignore_check_for_db_index: false } end |
Instance Attribute Details
#token_attribute ⇒ Object (readonly)
Returns the value of attribute token_attribute.
53 54 55 |
# File 'lib/shoulda/matchers/active_record/have_secure_token_matcher.rb', line 53 def token_attribute @token_attribute end |
Instance Method Details
#description ⇒ Object
60 61 62 |
# File 'lib/shoulda/matchers/active_record/have_secure_token_matcher.rb', line 60 def description "have :#{token_attribute} as a secure token" end |
#failure_message ⇒ Object
64 65 66 67 68 69 |
# File 'lib/shoulda/matchers/active_record/have_secure_token_matcher.rb', line 64 def return if !@errors "Expected #{@subject.class} to #{description} but the following " \ "errors were found: #{@errors.join(', ')}" end |
#failure_message_when_negated ⇒ Object
71 72 73 74 75 76 |
# File 'lib/shoulda/matchers/active_record/have_secure_token_matcher.rb', line 71 def return if !@errors "Did not expect #{@subject.class} to have secure token " \ ":#{token_attribute}" end |
#ignoring_check_for_db_index ⇒ Object
84 85 86 87 |
# File 'lib/shoulda/matchers/active_record/have_secure_token_matcher.rb', line 84 def ignoring_check_for_db_index [:ignore_check_for_db_index] = true self end |
#matches?(subject) ⇒ Boolean
78 79 80 81 82 |
# File 'lib/shoulda/matchers/active_record/have_secure_token_matcher.rb', line 78 def matches?(subject) @subject = subject @errors = run_checks @errors.empty? end |