-
-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Matcher] Enhance descriptions and failure messages (#223)
- Loading branch information
Showing
18 changed files
with
307 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
lib/active_storage_validations/matchers/concerns/rspecable.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require "active_support/concern" | ||
|
||
module ActiveStorageValidations | ||
module Matchers | ||
module Rspecable | ||
extend ActiveSupport::Concern | ||
|
||
def initialize(attribute_name) | ||
super | ||
@failure_message_artefacts = [] | ||
end | ||
|
||
def description | ||
raise NotImplementedError, "#{self.class} did not define #{__method__}" | ||
end | ||
|
||
def failure_message | ||
raise NotImplementedError, "#{self.class} did not define #{__method__}" | ||
end | ||
|
||
def failure_message_when_negated | ||
failure_message.sub(/is expected to validate/, 'is expected not to validate') | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.