Created
February 10, 2011 15:11
-
-
Save tmilewski/820666 to your computer and use it in GitHub Desktop.
Verbose be_valid RSpec matcher
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
RSpec::Matchers.define :be_valid do | |
match do |model| | |
model.valid? | |
end | |
failure_message_for_should do |model| | |
"expected valid? to return true, got false:\n #{model.errors.full_messages.join("\n ")}" | |
end | |
failure_message_for_should_not do |model| | |
"expected valid? to return false, got true" | |
end | |
description do | |
"be valid" | |
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
1) Video while creating should be valid | |
Failure/Error: @video.should be_valid | |
expected valid? to return true, got false due to the following errors: | |
Youtube url is invalid | |
Youtube url can't be blank | |
# ./spec/models/video_spec.rb:29 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment