The following statements will save you lots of time, and most
importantly, develop a better application when beginning Rails
Fixtures are faster, but conciseness is more important. Use factories
(Machinist or Factory girl). Don't worry about the speed of your test/
spec suite. Use autotest or autospec.
--- I started out with fixtures, then switched to factories. Lost
patience and switched back to fixtures. Now back to factories for
maintainability and conciseness.
Do not mock everything to make your test/spec suite "database
independent". Your tests are SUPPOSED to break when you change code in
your model or controller. Mocking everything will not allow this, and
will give you the feeling that you're developing a second application
in your test/spec suite.
--- Yes, it will speed up your tests/specs, but once again,
conciseness is more important.
Your test framework does not matter. Test/unit, Shoulda, RSpec all
produce the same outcome. Choose by what syntax you feel comfortable
with. For every great developer that uses test/unit, there is a great
developer using RSpec.
--- For whatever reason I cannot explain, RSpec feels most comfortable
to me. I started with test/unit, switched to RSpec, then shoulda, then
test/unit, and now back to RSpec. I will not switch again.
Test the entire stack. Do not just test models. Test/spec models,
controllers, and use integration tests/specs. This will give you
confidence when developing and literally makes your work 1000 times
less stressful. Yes, it takes more time, but it is the ONLY way to
develop a reliable app that works.
--- I started out just testing models. This does not catch view
errors, and my users paid for it.
If TDD or BDD does not fit your brain, don't do it. DHH doesn't do it,
and you don't have to either. This is no excuse for not testing
--- For me, TDD/BDD does not let me test/spec comfortably. I tried
both ways, and my code always turns out better when NOT using TDD/BDD.
I support the philosophy, but it is not "necessary". Some people will
say I am "doing it wrong", but if the end outcome is exactly what I
want, why does it matter how I got there?
If I had known these things when beginning, I would have saved
countless hours trying to follow the "one golden path" that does not
exist. I hope this helps.