Skip to content

Commit

Permalink
Docs for running specs on Zepto
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Nov 1, 2013
1 parent 6cacc6f commit 7bde6f1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -268,6 +268,12 @@ Run the tests inside a phantom.js runner:

$ bundle exec rake

### Zepto

opal-jquery also supports zepto. To run specs for zepto use the rake task:

$ bundle exec rake zepto

## License

(The MIT License)
Expand Down
54 changes: 28 additions & 26 deletions spec/spec_helper.rb
@@ -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

0 comments on commit 7bde6f1

Please sign in to comment.