Sha256: 67f93ba7893d698470009c59dc6da07e4fa1e6eff5803f4ac6aa978dad86a787

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'

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

  before do
    Capybara.default_driver = :selenium
    prickly.visit '/'
  end

  context 'Extended waits', :javascript => true 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 => 'lagged').contains_text? "I lag" }.to raise_error Capybara::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 Capybara::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

2 entries across 2 versions & 1 rubygems

Version Path
prickle-0.0.5 spec/extended_wait_spec.rb
prickle-0.0.4 spec/extended_wait_spec.rb