Last active
August 29, 2015 14:15
-
-
Save giedriusr/185389594cdff292bd6c to your computer and use it in GitHub Desktop.
rspec 3.0
This file contains hidden or 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
# Documentation | |
# https://relishapp.com/rspec/rspec-expectations/v/3-0/docs/built-in-matchers | |
# expect(actual).to exist # passes if actual.exist? and/or actual.exists? are truthy | |
### Class | |
Member < ActiveRecord:Base | |
end | |
### Specs | |
# wrong | |
member = Member.find_by(group_id: group_id) | |
expect(member).to exist | |
Failure/Error: expect(member).to exist | |
expected #<Member ..> to exist but it does not respond to either `exist?` or `exists?` | |
# correct | |
member = Member.where(group_id: group_id) | |
expect(member).to exist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment