Behaviour Driven Development for Ruby. Documentation by example can be found on relishapp.com/rspec .
`describe` should be used with `classes` or `#methods`
YOUTUBE URSWYvyc42M Rails Conf 2013 - The Magic Tricks of Testing
`context` describes application state which should be manipulated into place using `before`.
Unit Testing Minimalist, credit to Sandi Metz taken from her talk on The Magic Tricks of Testing .
`let` blocks should describe static resources to be used in the context of a test. Behaviours specific to contexts can be overridden by redefining a let in that context.
Try pull methods out of `ActiveRecord`s into services. This allows your models to be declarative, and means you can mock models with lightweight rspec mocks .
let(:game) { double(:game, :lives => 8) } before do foo.stub(:won?) { true } end
When testing Helpers or Services, ideally we do not want to know the collaborator. That's too specific, and we should instead be mocking up the collaborators. You can mock objects with `double`.
When testing services that produce side affects, do be weary to only use declarative properties of models such as scopes and attr_reader variables.
That is to say, services should not test logic on your Rails Models.
If you're end to end testing, consider using a tool like VCR