- One method = One
describe
- Use
-foo
for instance methods - Use
+foo
for class methods - Use
.foo
for properties - Use
<ProtocolName>methodname:
for delegate methods - Use
context
inside ofdescribe
to describe the behavior for a specific state - Use
it
blocks to verify specific behavior - Describe what is happening, not what should happen.
it does something
instead ofit should do something
- One assertion per
it
block - Don't test private methods (User visible stuff is public)
- Extract method parameters that matter for the context (for example in
beforeEach
)
http://betterspecs.org/
https://github.com/howaboutwe/rspec-style-guide
http://blog.carbonfive.com/2010/10/21/rspec-best-practices/
http://jakegoulding.com/presentations/rspec-structure/