Sha256: 35681cabae574c90ebc202c946f48c0b120770318cfe4bebab073b375d1f9ce4

Contents?: true

Size: 910 Bytes

Versions: 2

Compression:

Stored size: 910 Bytes

Contents

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

module OpalTest
  class TestCase

    # 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

2 entries across 2 versions & 1 rubygems

Version Path
opal-jquery-0.0.8 spec/spec_helper.rb
opal-jquery-0.0.7 spec/spec_helper.rb