Skip to content

Instantly share code, notes, and snippets.

@RobinDaugherty
Last active December 17, 2015 21:26
Show Gist options
  • Save RobinDaugherty/c77135a16b126677f920 to your computer and use it in GitHub Desktop.
Save RobinDaugherty/c77135a16b126677f920 to your computer and use it in GitHub Desktop.
Rails spec cleanup
# Opens each model file alongside its corresponding spec file, even if the spec file doesn't yet exist.
# Waits for you to close the files before loading the next pair.
for i in app/models/**.rb; do
mate -w $i ${${i/app/spec}/.rb/_spec.rb}
done
# Opens each model file alongside its corresponding spec file if the model contains "serialize".
# Waits for you to close the files before loading the next pair.
for i in app/models/**.rb; do
grep serialize $i && mate -w $i ${${i/app/spec}/.rb/_spec.rb}
done
# Opens each model spec file that Rubocop has a complaint about. You can see the complaints in the output.
# Waits for you to close the files before loading the next pair.
for i in spec/models/**.rb; do
rubocop $i || mate -w $i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment