Sha256: 31a080393dc59e1345dedcdbbcd304b20ce8fe7994936ada97feb23daa026a98

Contents?: true

Size: 732 Bytes

Versions: 2

Compression:

Stored size: 732 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
    lambda {
      Element.new.some_unknown_plugin
    }.should raise_error(NoMethodError)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-jquery-0.1.0 spec/element/method_missing_spec.rb
opal-jquery-0.0.13 spec/element/method_missing_spec.rb