Sha256: 6a47b65a98a542018dc65f03cd20e278fed8d806ac074d702b8dbacd917d98c0

Contents?: true

Size: 1.26 KB

Versions: 82

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

class NodeWrapper
  def initialize(element); @element = element end
  def to_capybara_node(); @element end
end

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

  it 'should support have_xxx expectations' do
    para = NodeWrapper.new(@session.find(:css, '#first'))
    expect(para).to have_link('ullamco')
  end

  it 'should support within' do
    para = NodeWrapper.new(@session.find(:css, '#first'))
    expect(@session).to have_css('#second')
    @session.within(para) do
      expect(@session).to have_link('ullamco')
      expect(@session).not_to have_css('#second')
    end
  end

  it 'should generate correct errors' do
    para = NodeWrapper.new(@session.find(:css, '#first'))
    expect do
      expect(para).to have_text('Header Class Test One')
    end.to raise_error(/^expected to find text "Header Class Test One" in "Lore/)
    expect do
      expect(para).to have_css('#second')
    end.to raise_error(/^expected to find css "#second" within #<Capybara::Node::Element/)
    expect do
      expect(para).to have_link(href: %r{/without_simple_html})
    end.to raise_error(%r{^expected to find link nil with href matching /\\/without_simple_html/ within #<Capybara::Node::Element})
  end
end

Version data entries

82 entries across 69 versions & 4 rubygems

Version Path
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/capybara-3.34.0/lib/capybara/spec/session/node_wrapper_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/spec/session/node_wrapper_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/spec/session/node_wrapper_spec.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/capybara-3.35.3/lib/capybara/spec/session/node_wrapper_spec.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/capybara-3.34.0/lib/capybara/spec/session/node_wrapper_spec.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/capybara-3.34.0/lib/capybara/spec/session/node_wrapper_spec.rb
tdiary-5.1.5 vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/spec/session/node_wrapper_spec.rb
capybara-3.35.3 lib/capybara/spec/session/node_wrapper_spec.rb
capybara-3.35.2 lib/capybara/spec/session/node_wrapper_spec.rb
capybara-3.35.1 lib/capybara/spec/session/node_wrapper_spec.rb
capybara-3.35.0 lib/capybara/spec/session/node_wrapper_spec.rb
tdiary-5.1.4 vendor/bundle/ruby/2.7.0/gems/capybara-3.34.0/lib/capybara/spec/session/node_wrapper_spec.rb
capybara-3.34.0 lib/capybara/spec/session/node_wrapper_spec.rb
tdiary-5.1.3 vendor/bundle/ruby/2.7.0/gems/capybara-3.33.0/lib/capybara/spec/session/node_wrapper_spec.rb
tdiary-5.1.3 vendor/bundle/ruby/2.6.0/gems/capybara-3.32.2/lib/capybara/spec/session/node_wrapper_spec.rb
capybara-3.33.0 lib/capybara/spec/session/node_wrapper_spec.rb
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/capybara-3.29.0/lib/capybara/spec/session/node_wrapper_spec.rb
tdiary-5.1.2 vendor/bundle/ruby/2.7.0/gems/capybara-3.32.2/lib/capybara/spec/session/node_wrapper_spec.rb
capybara-3.32.2 lib/capybara/spec/session/node_wrapper_spec.rb
capybara-3.32.1 lib/capybara/spec/session/node_wrapper_spec.rb