axiom icon indicating copy to clipboard operation
axiom copied to clipboard

Combine per-method specs into per-class organization

Open dkubb opened this issue 10 years ago • 4 comments

@solnic @mbj @snusnu do you guys have any tools you've written to do this conversion? I'm willing to try it out.

dkubb avatar May 22 '14 04:05 dkubb

No, not really. I'm not sure if it would be simple enough to build one to be honest. btw I still have this organization in most of the projects.

Are you thinking about refactoring axiom's spec suite? Because I can totally help. In rom's fork I moved spec/unit to spec-old/unit and I planned to start refactoring (after ast is more or less done) by porting old ones to new ones step-by-step whenever I find time/energy. It would be the best opportunity for me to learn axiom's internals better.

solnic avatar May 22 '14 07:05 solnic

@dkubb I perform this normally via some shell + vim batch editing. Not too much automated.

mbj avatar May 22 '14 09:05 mbj

Are you thinking about refactoring axiom's spec suite?

@solnic I was thinking about it. I still really do like the per-method specs, but I realize lots of others don't like it so I'm willing to test per-class specs to see what the change is.

I perform this normally via some shell + vim batch editing. Not too much automated.

@mbj I was thinking it might be possible to parse the spec files with parser, then combine the asts per-class, then do one or more optimization passes to pull up common let() and before() blocks to the parent scope. We could then use unparser to write out the code, use rubocop to see if there's any weird formatting issues, and then manually fix the formatting of the rest.

This might be a make-work project, and it may be possible to do this with shell/perl and a getting my hands dirty. I was just trying to think if there's a simple approach that can produce combined spec files close to what I would write by hand.

dkubb avatar May 22 '14 15:05 dkubb

@dkubb for me per-method specs aren't the biggest concern. Here's a list of things I no longer like in no particular order:

  • implicit subjects
  • using let(:object) to establish object-under-test
  • lack of meaningful example descriptions
  • nesting contexts and doing tricks with let to avoid duplication
  • many shared contexts (this is probably related to per-method approach)
  • extensive usage of mocks
  • generating spec examples (in rare cases it makes sense)
  • over-testing by specifying every detailed behavior a method has (ie testing that #each returns self or that a method doesn't mutate an object and probably many more)

So, I'd love to improve that however I'm not exactly sure how you feel about this so I figured I'll just start with a few tests and show it for a review :)

solnic avatar May 22 '14 16:05 solnic