Sha256: a8a308f3ec73b9260eba820502e5c411a7554e58af5b24048ebc458477d5e84c

Contents?: true

Size: 909 Bytes

Versions: 4

Compression:

Stored size: 909 Bytes

Contents

require 'jquery'
require 'opal-spec'
require 'opal-jquery'

module OpalSpec
  class Example

    # 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 }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
opal-jquery-0.0.13 spec/spec_helper.rb
opal-jquery-0.0.12 spec/spec_helper.rb
opal-jquery-0.0.11 spec/spec_helper.rb
opal-jquery-0.0.9 spec/spec_helper.rb