-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
6cacc6f
commit 7bde6f1
Showing
2 changed files
with
34 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,35 @@ | ||
require 'opal-spec' | ||
require 'opal-jquery' | ||
|
||
module OpalSpec | ||
class Example | ||
module JqueryHelpers | ||
# Add some html code to the body tag ready for testing. This will | ||
# be added before each test, then removed after each test. It is | ||
# convenient for adding html setup quickly. The code is wrapped | ||
# inside a div, which is directly inside the body element. | ||
# | ||
# describe "DOM feature" do | ||
# html <<-HTML | ||
# <div id="foo"></div> | ||
# HTML | ||
# | ||
# it "foo should exist" do | ||
# Document["#foo"] | ||
# end | ||
# end | ||
# | ||
# @param [String] html_string html content to add | ||
def html(html_string='') | ||
html = %Q{<div id="opal-jquery-test-div">#{html_string}</div>} | ||
|
||
# Add some html code to the body tag ready for testing. This will | ||
# be added before each test, then removed after each test. It is | ||
# convenient for adding html setup quickly. The code is wrapped | ||
# inside a div, which is directly inside the body element. | ||
# | ||
# describe "DOM feature" do | ||
# html <<-HTML | ||
# <div id="foo"></div> | ||
# HTML | ||
# | ||
# it "foo should exist" do | ||
# Document["#foo"] | ||
# end | ||
# end | ||
# | ||
# @param [String] html_string html content to add | ||
def self.html(html_string='') | ||
html = '<div id="opal-jquery-test-div">' + html_string + '</div>' | ||
before do | ||
@_spec_html = Element.parse(html) | ||
@_spec_html.append_to_body | ||
end | ||
|
||
after { @_spec_html.remove } | ||
before do | ||
@_spec_html = Element.parse(html) | ||
@_spec_html.append_to_body | ||
end | ||
|
||
after { @_spec_html.remove } | ||
end | ||
end | ||
|
||
class OpalSpec::Example | ||
extend JqueryHelpers | ||
end |