Today I Learned

A Hashrocket project

Hound -> Create, Open, then Delete a Screenshot

While running integration tests with Hound, I wanted my test to take a screenshot, open it, and remove the screenshot after the test runs.

def screenshot do
  shot = take_screenshot
  System.cmd("open",  [shot])
  on_exit fn ->
    :timer.sleep 500
    File.rm(shot)
  end
end

…like a charm :)

Looking for help? At Hashrocket, we 💜 Elixir! From our many Elixir client projects, to sponsoring the Chicago Elixir Meetup, to the source code for this application, we are invested in this community. Contact us today to talk about your Elixir project.