Added basic test cases for resume model#52
Added basic test cases for resume model#52jasonkhoe wants to merge 1 commit intocompserv:masterfrom jasonkhoe:rspec-resume-model
Conversation
There was a problem hiding this comment.
One guideline for writing good tests is that you shouldn't be testing the same thing in multiple test cases. In this case, you can have a separate test for testing "should not be valid". In fact, you might even just leave out the check for "should_not be_valid" because the other tests imply that the resume isn't valid.
There was a problem hiding this comment.
I'm kind of confused here. Is the issue that I'm testing should_not be_valid in multiple test cases?
There was a problem hiding this comment.
Yes, exactly. Ideally, you should be able to tell what a bug is from which tests are failing. The way they're currently written, if a resume isn't valid when created with no parameters, then every one of these tests will fail.
There was a problem hiding this comment.
So if there's a test that basically says it "should not be valid", what am I supposed to write regarding test cases for the various validations in the model (presence, range, etc.)? I was modeling the test after some of the other model specs here, but they also repeatedly test should_not be_valid.
Sorry about asking so many questions.
There was a problem hiding this comment.
Most of our tests are honestly not written very well. You should be able to just remove all the should_not be_valid statements, since the @resume.errors checks already imply not valid.
|
Overall, 👍 on writing tests and 👍 on code style in general. If you're interested in extra reading, I'd recommend this book, written by the creator of RSpec on Cucumber and RSpec: http://pragprog.com/book/achbd/the-rspec-book |
Added some basic test cases for the Resume model. Still needs test cases for file uploads and PDF validation.
Written in response to this Redmine issue: https://hkn.eecs.berkeley.edu/redmine/issues/98
Oh, and I haven't modified the model yet to actually pass these tests, most of which actually fail.
Looking for feedback, this is the first time I've written an Rspec test, so not sure if I'm following best practices here.