Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pawlik
Last active October 3, 2016 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pawlik/41d69bad61920cee3db319f9a6749da4 to your computer and use it in GitHub Desktop.
Save pawlik/41d69bad61920cee3db319f9a6749da4 to your computer and use it in GitHub Desktop.
Run related specs whenever you touch shared_example file
# run specs using shared examples after touching shared example itself
watch(%r'spec/support/shared_examples/.*\.rb') do |m|
m.each_with_object([]) do |m, files|
defline = `grep shared_example.*$ #{m}`
shared_example_name = %r[shared_examples ["':](.*)["'] do].match(defline)[1]
new_files =
`grep -r #{shared_example_name} spec/ --include="*_spec.rb" | grep -E "spec/.*_spec\.rb" -o`.split("\n")
files.concat(new_files)
end
end
@pawlik
Copy link
Author

pawlik commented Sep 29, 2016

unfortunately it runs whole specs, changing it to

   `grep -rn #{shared_example_name} spec/ --include="*_spec.rb" | grep -E "spec/.*_spec\.rb\:[0-9]*" -o`.split("\n")

doesn't make it run only lines containing it_behaves_like, not sure why.

@pawlik
Copy link
Author

pawlik commented Oct 3, 2016

this is not working for (apq/ba/talent/save_application_spec.rb), check this out later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment