Sha256: 0ebfe13d2227dfa2b547f5d82adca5b12a48a4eec51324d5808de8d759a3931a

Contents?: true

Size: 836 Bytes

Versions: 6

Compression:

Stored size: 836 Bytes

Contents

# frozen_string_literal: true

Capybara::SpecHelper.spec '#current_scope' do
  before do
    @session.visit('/with_scope')
  end

  context 'when not in a #within block' do
    it 'should return the document' do
      expect(@session.current_scope).to be_a Capybara::Node::Document
    end
  end

  context 'when in a #within block' do
    it 'should return the element in scope' do
      @session.within(:css, '#simple_first_name') do
        expect(@session.current_scope[:name]).to eq 'first_name'
      end
    end
  end

  context 'when in a nested #within block' do
    it 'should return the element in scope' do
      @session.within("//div[@id='for_bar']") do
        @session.within(".//input[@value='Peter']") do
          expect(@session.current_scope[:name]).to eq 'form[first_name]'
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/capybara-3.40.0/lib/capybara/spec/session/current_scope_spec.rb
capybara-3.40.0 lib/capybara/spec/session/current_scope_spec.rb
capybara-3.39.2 lib/capybara/spec/session/current_scope_spec.rb
capybara-3.39.1 lib/capybara/spec/session/current_scope_spec.rb
capybara-3.39.0 lib/capybara/spec/session/current_scope_spec.rb
capybara-3.38.0 lib/capybara/spec/session/current_scope_spec.rb