spec/watirspec/screenshot_spec.rb in watir-7.2.0 vs spec/watirspec/screenshot_spec.rb in watir-7.2.1
- old
+ new
@@ -1,31 +1,33 @@
# frozen_string_literal: true
require 'base64'
require 'watirspec_helper'
-describe 'Watir::Screenshot' do
- let(:png_header) { (+"\211PNG").force_encoding('ASCII-8BIT') }
+module Watir
+ describe Screenshot do
+ let(:png_header) { (+"\211PNG").force_encoding('ASCII-8BIT') }
- describe '#png' do
- it 'gets png representation of screenshot' do
- expect(browser.screenshot.png[0..3]).to eq png_header
+ describe '#png' do
+ it 'gets png representation of screenshot' do
+ expect(browser.screenshot.png[0..3]).to eq png_header
+ end
end
- end
- describe '#base64' do
- it 'gets base64 representation of screenshot' do
- image = browser.screenshot.base64
- expect(Base64.decode64(image)[0..3]).to eq png_header
+ describe '#base64' do
+ it 'gets base64 representation of screenshot' do
+ image = browser.screenshot.base64
+ expect(Base64.decode64(image)[0..3]).to eq png_header
+ end
end
- end
- describe '#save' do
- it 'saves screenshot to given file' do
- path = "#{Dir.tmpdir}/test#{Time.now.to_i}.png"
- expect(File).to_not exist(path)
- browser.screenshot.save(path)
- expect(File).to exist(path)
- expect(File.binread(path)[0..3]).to eq png_header
+ describe '#save' do
+ it 'saves screenshot to given file' do
+ path = "#{Dir.tmpdir}/test#{::Time.now.to_i}.png"
+ expect(File).not_to exist(path)
+ browser.screenshot.save(path)
+ expect(File).to exist(path)
+ expect(File.binread(path)[0..3]).to eq png_header
+ end
end
end
end