Sha256: 8e7d054d89d4a8ee71caccfe2ed231a46cc64a54db115b0fd53b42f64d16185d

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'
require 'gnawrnip/screenshot'

module Gnawrnip
  describe Screenshot do
    context 'Not support save_screenshot' do
      describe '.tale' do
        before do
          GnawrnipTest::Session.any_instance.stub(:save_screenshot) do
            raise Capybara::NotSupportedByDriverError
          end
        end

        it 'should raise Capybara::NotSupportByDriverError' do
          expect { Screenshot.take }.to raise_error Capybara::NotSupportedByDriverError
        end
      end
    end

    context 'raise unknown error' do
      describe '.take' do
        before do
          GnawrnipTest::Session.any_instance.stub(:save_screenshot) do
            raise Timeout::Error
          end
        end

        context 'timeout' do
          before do
            now = Time.now
            Time.stub(:now).and_return(now, now + 3)
          end

          it 'should raise Timeout Error' do
            screenshot = Capybara.using_wait_time 2 do
              Screenshot.take
            end

            expect(screenshot).to be_nil
          end
        end
      end
    end

    context 'success screenshot' do
      describe '.take' do
        before do
          Screenshot.should_receive(:shot).once
        end

        it { Screenshot.take }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gnawrnip-0.2.5 spec/gnawrnip/screenshot_spec.rb