Skip to content

Remove dir prefix from filename of tests under dir.

Ramya Authappan requested to merge github/fork/booktree/rm-dir-prefix into master

Created by: cirosantilli

Rename refactoring only commit. E.g.:

  • rename features/project/commits/commit_comments.feature to comments.feature
  • rename features/steps/project/project_wiki.rb to wiki.rb
  • rename features/steps/snippets/user_snippets.rb to user.rb

Advantages

  • its DRYer: before we repeated the directory name in the files it contain.
  • we type less: every time I want to select a project_X file I have to do pro<tab>X<tab>. This lets us do only X<tab> instead.
  • it is more uniform: certain tests were already breaking the dir prefix "rule" before this commit, e.g.:
    • features/steps/project/deploy_keys.rb already did not have the prefix before.
    • under steps, most files already don't contain the dir prefix. This removes it from the few that do.

Disadvantages

The only downside I can see is that if your editor only shows basenames on tabs, you can't tell some files apart. However:

  • when working on a branch, it is likely that you will only touch files under a single directory.
  • if you use a good editor (e.g. Vim) you can configure it to show parent/basename on tabs instead.

Therefore, I feel that the advantages outweight the disadvantages.

doubts

  • Exception was made for files such as project/project.rb, which are unchanged. What if we rename those as main.rb or shared.rb to be DRYer?
  • What if we rename all suffixes classes like PublicProjects < Spinach::FeatureSteps to prefix classes like ProjectsPublic, which is already the case for the majority of tests? This would make this refactoring even neater.

Merge request reports

Loading