Given that this is a unit test, you should mock from_file
. There's no benefit in testing ChunkyPNG; I trust its authors already tested it for you. In your examples for this method:
image = double image # ha, I said "double image"
expect(ChunkyPNG::Image).to receive(:from_file).with(# whatever screenshot path should be) { image }
expect(ImageManipulation).to receive(:get_bg_from_edges).with(image) { # whatever background you like }
You probably want an integration test that hits this code too (in fact I'd have written that first), and then you would actually want an image on the disk to read. Whether you'd need to put it there as part of the integration test setup or whether your app should put it there depends on your app.