Sha256: ff59a0b4b6d926f8e87818b75279b658b15ab4d5593b5c441fc26b99105d2385

Contents?: true

Size: 883 Bytes

Versions: 4

Compression:

Stored size: 883 Bytes

Contents

require 'opal-rspec'
require 'opal-jquery'

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

    before do
      @_spec_html = Element.parse(html)
      @_spec_html.append_to_body
    end

    after { @_spec_html.remove }
  end
end

RSpec.configure do |config|
  config.extend JqueryHelpers
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
opal-jquery-0.3.0.beta1 spec/spec_helper.rb
opal-jquery-0.2.0 spec/spec_helper.rb
opal-jquery-0.1.2 spec/spec_helper.rb
opal-jquery-0.1.1 spec/spec_helper.rb