Skip to content

Instantly share code, notes, and snippets.

@RyanScottLewis
Created May 1, 2012 10:47
Show Gist options
  • Select an option

  • Save RyanScottLewis/2567257 to your computer and use it in GitHub Desktop.

Select an option

Save RyanScottLewis/2567257 to your computer and use it in GitHub Desktop.
Rspec: clear terminal before suites in OSX
# omitted...
RSpec.configure do |config|
# omitted...
config.before(:suite) do
if RUBY_PLATFORM =~ /darwin/
# Focus on Terminal
system %{osascript -e 'tell application "Terminal" to activate'}
# Send CMD+K to clear
system %{osascript -e 'if application "Terminal" is frontmost then tell application "System Events" to keystroke "k" using command down'}
# CMD-TAB to return focus to previous application
system %{osascript -e 'tell application "System Events" to keystroke tab using command down'}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment