1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00
teamcapybara--capybara/lib/capybara/spec/session/screenshot_spec.rb
Greg Lazarev dbd0d8b3ef Add ability to save and open screenshot
This adds a new method `save_and_open_screenshot` that saves the screenshot then
opens it for inspection.

Refactor duplicate logic for `save_and_open_page` and `save_and_open_screenshot`
2014-04-03 13:40:18 -07:00

16 lines
407 B
Ruby

#coding: US-ASCII
Capybara::SpecHelper.spec "#save_screenshot" do
let(:image_path) { File.join(Dir.tmpdir, 'capybara-screenshot.png') }
before do
@session.visit '/'
end
it "should generate PNG file", :requires => [:screenshot] do
path = @session.save_screenshot image_path
magic = File.read(image_path, 4)
expect(magic).to eq "\x89PNG"
expect(path).to eq image_path
end
end