Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine per-method specs into per-class organization #57

Open
dkubb opened this issue May 22, 2014 · 4 comments
Open

Combine per-method specs into per-class organization #57

dkubb opened this issue May 22, 2014 · 4 comments

Comments

@dkubb
Copy link
Owner

dkubb commented May 22, 2014

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

@solnic
Copy link
Collaborator

solnic commented May 22, 2014

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.

@mbj
Copy link
Collaborator

mbj commented May 22, 2014

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

@dkubb
Copy link
Owner Author

dkubb commented May 22, 2014

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.

@solnic
Copy link
Collaborator

solnic commented May 22, 2014

@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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants