{"action":"created","issue":{"url":"https://api.github.com/repos/cobudget/cobudget-api/issues/67","labels_url":"https://api.github.com/repos/cobudget/cobudget-api/issues/67/labels{/name}","comments_url":"https://api.github.com/repos/cobudget/cobudget-api/issues/67/comments","events_url":"https://api.github.com/repos/cobudget/cobudget-api/issues/67/events","html_url":"https://github.com/cobudget/cobudget-api/pull/67","id":79216242,"number":67,"title":"model testing","user":{"login":"euglazer","id":7520103,"avatar_url":"https://avatars.githubusercontent.com/u/7520103?v=3","gravatar_id":"","url":"https://api.github.com/users/euglazer","html_url":"https://github.com/euglazer","followers_url":"https://api.github.com/users/euglazer/followers","following_url":"https://api.github.com/users/euglazer/following{/other_user}","gists_url":"https://api.github.com/users/euglazer/gists{/gist_id}","starred_url":"https://api.github.com/users/euglazer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/euglazer/subscriptions","organizations_url":"https://api.github.com/users/euglazer/orgs","repos_url":"https://api.github.com/users/euglazer/repos","events_url":"https://api.github.com/users/euglazer/events{/privacy}","received_events_url":"https://api.github.com/users/euglazer/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-22T00:22:59Z","updated_at":"2015-05-22T03:16:35Z","closed_at":"2015-05-22T00:42:37Z","pull_request":{"url":"https://api.github.com/repos/cobudget/cobudget-api/pulls/67","html_url":"https://github.com/cobudget/cobudget-api/pull/67","diff_url":"https://github.com/cobudget/cobudget-api/pull/67.diff","patch_url":"https://github.com/cobudget/cobudget-api/pull/67.patch"},"body":"wrote a bunch of model tests as a first step towards getting my head around this api"},"comment":{"url":"https://api.github.com/repos/cobudget/cobudget-api/issues/comments/104487248","html_url":"https://github.com/cobudget/cobudget-api/pull/67#issuecomment-104487248","issue_url":"https://api.github.com/repos/cobudget/cobudget-api/issues/67","id":104487248,"user":{"login":"jonlemmon","id":1179717,"avatar_url":"https://avatars.githubusercontent.com/u/1179717?v=3","gravatar_id":"","url":"https://api.github.com/users/jonlemmon","html_url":"https://github.com/jonlemmon","followers_url":"https://api.github.com/users/jonlemmon/followers","following_url":"https://api.github.com/users/jonlemmon/following{/other_user}","gists_url":"https://api.github.com/users/jonlemmon/gists{/gist_id}","starred_url":"https://api.github.com/users/jonlemmon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonlemmon/subscriptions","organizations_url":"https://api.github.com/users/jonlemmon/orgs","repos_url":"https://api.github.com/users/jonlemmon/repos","events_url":"https://api.github.com/users/jonlemmon/events{/privacy}","received_events_url":"https://api.github.com/users/jonlemmon/received_events","type":"User","site_admin":false},"created_at":"2015-05-22T03:16:35Z","updated_at":"2015-05-22T03:16:35Z","body":"Hey Eugene, cool!!! Great to see you contributing here. :)\r\n\r\nI noticed your editor might have been set to indent with tabs instead of spaces for some of the files? Generally all ruby code is written with 2 spaces for indentation (tabs are considered evil).\r\n\r\nAlso, [Warning: strong personal perspective about to be voiced] I may have mentioned this to you before, but I think \"shoulda\" tests are a waste of time. Especially when the code in the model looks pretty much identical to what you're writing in the test. Like, what is that testing really? Does it make you feel anymore confident about what you're coding? I know it doesn't for me.\r\n\r\nKent Beck said, \"I get paid for code that works, not for tests, so my philosophy is to test as little as possible to reach a given level of confidence... If I don’t typically make a kind of mistake (like setting the wrong variables in a constructor), I don’t test for it.\" \r\n\r\nSo like, testing simple validations, really? I recommend giving both these articles from DHH (the creator of Rails) a read:\r\n\r\nhttp://david.heinemeierhansson.com/2014/test-induced-design-damage.html\r\nhttp://signalvnoise.com/posts/3159-testing-like-the-tsa\r\n\r\nI used to think DHH was a dick and not worth listening to ([here's some slightly embarrassing proof](https://twitter.com/jon_lemmon/status/284075141967790080)), but then I read those posts and they totally changed the way I work. I used to try to test everything perfectly. But something always felt not-quite-right. I couldn't quite put my finger on it, but then I read those articles, and I realized that somewhere early on in my programming career I had, without much consideration, joined \"The Church Of TDD\". Judging by your pull request, I think you may have joined it too. I guess you were raised in it, so who could blame you? There are so many people who you love and trust telling you that it's the one single truth that you must follow. But speaking as someone who was a part of that church and then left, trust me man, it's way better out here!\r\n\r\nOnce you stop religiously unit testing everything you start working way quicker and you write better code because you're more focused on what actually matters. When you DO write unit tests, it's because you've come across something tricky and you need a bit of help, and it feels REALLY GOOD to write the tests, because you're using them in the correct context. (Note that I'm speaking about *unit* tests here. I still write integration tests for every API point. They are quick to write and they give me a lot of confidence about the entire system.)\r\n\r\nOne thing Rob Guthrie used to always tell me when I was getting stuck on a particular test was \"Does it feel like this test is helping you right now or holding you back? If it's holding you back, just delete it and move on.\" Rob was constantly encouraging me to delete tests and not worry about replacing them right away. It was good advice, but it was often hard for me to swallow.\r\n\r\nNow that I've left the Church, I've noticed that there is a real art in deciding what to test, when to refactor, etc. I think this goes against our nature as engineers. We want to do something the same way every time, follow the rules religiously, and keep everything super consistent. But actually, good programming is equal parts art and science. If you apply the rule that \"absolutely everything must be unit tested\", you take away the art. Be organized and systematic, but fight the urge to apply a single rule to every situation. Trust your instincts. That's the most important thing I've learned in programming. If something doesn't feel right, don't be afraid to break the rules and do something different. Program like a human, not a machine. The art comes first, then the science."}}