[LRUG] Missing tests in Rails upgrade

Graham Ashton graham at effectif.com
Wed Jun 25 10:12:08 PDT 2014


On 25 Jun 2014, at 17:42, Jonathon Horsman <jonno at spleatapp.com> wrote:

> The authlogic gem is used for logging in, and its encryption mechanism changed, meaning effectively no one could log in.
> 
> I'm struggling to conceive a test which would capture this...

I wouldn’t worry about having test coverage for that. I’d expect to find it when either:

- Trying the code out on a copy of my live environment, prior to making it live (e.g. on a staging server), or

- Automating my previous suggestion to produce a few “smoke tests” that I could run against a staging server whenever deploying new code. They’d be pretty simple (in the style of “if I turn it on, does smoke come out?”) and few in number.

I don’t tend to bother with the automation bit that often, but do it if I feel the benefits of doing so outweigh the cost of writing and running the script. I make that choice on a per project basis, based on the perceived risk of a problem like this sneaking through.

> Secondly, a POST stopped working and needed to be replaced with PATCH
> 
> Essentially my controller tests can call 'post' or 'get' or 'patch' on a method, and the named controller method will get invoked in the test.
> However in the real world, only an HTTP PATCH will work

> What test should pick this up? Do I need router tests for every controller test?

Should a test pick it up? I’m not sure that’s the right question.

I’d start with “would it cost less (over the lifetime of the project) to write and maintain tests to catch this class of error than the cost to the business if we ship a handful of similar bugs in future?”

There’s a few variables embedded in that question that I’d review in the context of every project. Most of the time, on the projects I tend to work on, the answer I arrive at is not to test for this class of bug. If I worked on a lot of apps where the side effects of the bug were likely to cost more than the cost of reducing the team’s productivity, I’d probably try and test it.

Technically though, I’d have thought the kind of test you’d want to actually catch the problem would be an integration test. Are they still called request specs in Rspec land?



-- 
Graham Ashton
Founder, Agile Planner
https://www.agileplannerapp.com | @agileplanner | @grahamashton




More information about the Chat mailing list