Sha256: 3ad26a3ad62da4ba5259c583e72b04d646ad9e5c658417493189cb0331ed195c

Contents?: true

Size: 724 Bytes

Versions: 9

Compression:

Stored size: 724 Bytes

Contents

require "spec_helper"

# Add our jquery extension
%x{
  $.fn.opal_specs_extension = function() {
    return "foo_bar_baz";
  };

  $.fn.opal_specs_args = function() {
    return Array.prototype.slice.call(arguments);
  };
}

class Element
  expose :opal_specs_extension, :opal_specs_args
end

describe "Element#exposes" do
  it "exposes jquery plugins by given name" do
    Element.new.opal_specs_extension.should eq("foo_bar_baz")
  end

  it "forwards any args onto native function" do
    Element.new.opal_specs_args(:foo, 42, false).should eq([:foo, 42, false])
  end

  it "only forwards calls when a native method exists" do
    expect {
      Element.new.some_unknown_plugin
    }.to raise_error(Exception)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
opal-jquery-0.4.2 spec/element/method_missing_spec.rb
opal-jquery-0.4.1 spec/element/method_missing_spec.rb
opal-jquery-0.4.0 spec/element/method_missing_spec.rb
opal-jquery-0.3.0 spec/element/method_missing_spec.rb
opal-jquery-0.3.0.beta2 spec/element/method_missing_spec.rb
opal-jquery-0.3.0.beta1 spec/element/method_missing_spec.rb
opal-jquery-0.2.0 spec/element/method_missing_spec.rb
opal-jquery-0.1.2 spec/element/method_missing_spec.rb
opal-jquery-0.1.1 spec/element/method_missing_spec.rb