Sha256: 0a84350584960aff4e1f02d436d7f995cdbaf7b373232c247764426150eac682

Contents?: true

Size: 958 Bytes

Versions: 1

Compression:

Stored size: 958 Bytes

Contents

require 'spec_helper'

describe Browser::DOM::Document do
  describe '#title' do
    it 'should get the document title' do
      $document.title.should be_kind_of(String)
    end
  end

  describe '#title=' do
    it 'should set the document title' do
      old = $document.title
      $document.title = 'lol'
      $document.title.should == 'lol'
      $document.title = old
    end
  end

  describe "#[]" do
    html <<-HTML
      <div id="lol"></div>
    HTML

    it "should get element by id" do
      $document["lol"].should == `#{$document.to_n}.getElementById('lol')`
    end

    it "should get element by css" do
      $document["lol"].should == `#{$document.to_n}.getElementById('lol')`
    end

    it "should get element by xpath" do
      $document["//*[@id='lol']"].should == `#{$document.to_n}.getElementById('lol')`
    end

    it "should return nil if it can't find anything" do
      $document["doo-dah"].should be_nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-browser-0.1.0.beta1 spec/dom/document_spec.rb