3 ms·
I used the term variables to include a lot like attributes, and even some methods. If you are testing a model's attribute, then the test case definitely needs t
by bdclimber14 16y ago
I used the term variables to include a lot like attributes, and even some methods. If you are testing a model's attribute, then the test case definitely needs to know about it.
Technically, they are hooking up with the database since the attributes are automagically generated from the DB schema (using ActiveRecord on Rails). Maybe there's a better way? I'd love to know.
- ollysb 16y agoI love developing in rails but let's be clear, refactoring ruby is just painful at the moment. Yesterday I decided to rename a model, it took over an hour to get the tests passing again. Ok there's rubymine but it's only partially effective, it misses things like renaming relationships and references in templates. Given the difficulty of static analysis I've been wondering if a refactoring tool might look a little different with a dynamic language. Given that refactorings are effectively replacement patterns perhaps a find/replace workflow tool would be the way to go. The workflow might go something like: specify broad regex which matches all potential changes. View matches and then partition them with further rules like file type and tighter regexes. Once you've grouped the matches provide appropriate replacements. Run tests. Refine if required. Obviously you could follow this workflow using command line tools but the refinement process is difficult because you don't retain any of the context. Having said that it wouldn't be too hard to use existing commands to put something like this together. Looks I've got a project for this afternoon.
- jasonkester 16y agoThat there is the big reason I can never convince myself to stick with a language like Ruby or Python. I do about one project a year in one or the other, and am always re-amazed at the lack of proper tools. It's a shame, because in other ways they're so good. The refactor you mention is single right click in C# (with ReSharper, and without the frankly terrifying idea of using Regexes to do it). Compounding matters is the fact that a huge portion of your unit tests simply evaporate once you realize that you simply can't have typos or type mismatches in an old dinosaur language like C#. So it's entirely possible that that big suite of testcases it took so long to refactor would not be necessary at all (replaced instead by the occasional int x;). Once somebody gets the tools together so I can be as productive in Rails as I am in ASP.NET, I'm jumping ship. Until then, I'm hanging tight.
- ollysb 16y agoI'm a java refugee and used to make heavy use of the refactoring tools in eclipse. It's definitely something I miss from my old workflow. Given you're using BDD there isn't really anything to be concerned about when using regexes etc. to manipulate the code. I'd say that learning to use the command line better is essential if you move to a dynamic language. With regards to the test suites being larger due to type checking I think it's been fairly well established now that this isn't the case. Those types of errors are always shown up when testing other aspects of your code, I can't think of a single case where I've written tests that do any type checking. In the end I find that losing the refactoring assistance is a tradeoff that I'm happy to make in exchange for the increased expressivity and productivity I enjoy with rails.
- jasonkester 16y agoYou've piqued my curiosity. Why would a developer ever need to do anything (that affected his code) from the command line?
- ollysb 16y agoFind and replace is probably the only time I use the command line to actually modify the code. I could use a text editor to do this but favour the power I get with the command line(using ack and sed). Using the command line isn't necessary to work with rails but it is favoured within the culture. Generally people use it for everything from running the server to checking code in and as mentioned, refactoring.