Sha256: 44a0a2cb62449c1cb09c4c4e3425fcb4a28789ac52d7bfb0230aa400c7cf78af

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'

describe Prickle::Capybara do
  let(:prickly) { Prickly.new }

  before do
    prickly.visit '/'
  end

  context 'Extended waits', :javascript => true, :driver => :selenium do

    before(:each) do
      Prickle::Capybara.wait_time = nil
      prickly.visit '/'
    end

    context "matching text" do
      it 'can wait for an element to appear' do
        Prickle::Capybara.wait_time = 4
        prickly.element(:name => 'lagged').contains_text? "I lag"
      end

      it "can fail if an element doesn't appear after the default wait time" do
        Prickle::Capybara.wait_time = 1
        expect { prickly.element(:name => 'never_appear').contains_text? "I lag" }.to raise_error TimeoutError
      end
    end

    context "finding elements" do
      it 'can wait for an element to appear' do
        Prickle::Capybara.wait_time = 4
        prickly.find_by_name('lagged')
      end
    end

    context "clicking elements" do
      it 'fails to click an element that has not appeared yet' do
        Prickle::Capybara.wait_time = 1
        expect { prickly.click_by_name('lagged') }.to raise_error TimeoutError
      end

      it 'can click an element after it appears' do
        Prickle::Capybara.wait_time = 4
        prickly.click_by_name('lagged')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prickle-0.1.0 spec/extended_wait_spec.rb