maxwell / screencap

A gem to screencap webpages in ruby. Uses Phantom.js under the hood.
MIT License
179 stars 63 forks source link

How to stub Screencap in Rspec #14

Open snoblenet opened 9 years ago

snoblenet commented 9 years ago

I've tried numerous variations:

require 'screencap'

...and then each of the following:


Screencap.any_instance.stub(:fetch).and_return(File.open("#{Rails.root}/spec/support/stubbed_image.png"))

Fetcher::Screencap.any_instance.stub(:fetch).and_return(File.open("#{Rails.root}/spec/support/stubbed_image.png"))

Screencap.stub(:fetch).and_return(File.open("#{Rails.root}/spec/support/stubbed_image.png"))

Fetcher::Screencap(:fetch).and_return(File.open("#{Rails.root}/spec/support/stubbed_image.png"))

But I get various errors saying the various Rspec stubbing methods I require are not defined.