Skip to content

Commit

Permalink
Add Document.head and Document.body() methods
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Dec 10, 2013
1 parent 46a85a8 commit 00f5ae8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions opal/opal-jquery/document.rb
Expand Up @@ -14,6 +14,14 @@ def title
def title=(title)
`document.title = #{title}`
end

def head
Element.find(`document.head`)
end

def body
Element.find(`document.body`)
end
end

# TODO: this will be removed soon (here for compatibility)
Expand Down
16 changes: 16 additions & 0 deletions spec/document_spec.rb
@@ -1,6 +1,8 @@
require 'spec_helper'

describe Document do
subject { Document }

describe "ready?" do
it "accepts a block" do
Document.ready? { }
Expand All @@ -21,4 +23,18 @@
Document.title = old
end
end

describe "head" do
it "returns the head element as an Element instance" do
expect(subject.head).to be_kind_of(Element)
expect(subject.head.tag_name).to eq('head')
end
end

describe "body" do
it "returns the body element as an Element instance" do
expect(subject.body).to be_kind_of(Element)
expect(subject.body.tag_name).to eq('body')
end
end
end

0 comments on commit 00f5ae8

Please sign in to comment.