Sha256: da08831778574ead996ef118ac7b7c0cd2176ba181f9d3e9ea40850ac469ef47

Contents?: true

Size: 669 Bytes

Versions: 5

Compression:

Stored size: 669 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);
  };
}

describe "Element#method_missing" do
  it "calls 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

5 entries across 5 versions & 1 rubygems

Version Path
opal-jquery-0.0.12 spec/element/method_missing_spec.rb
opal-jquery-0.0.11 spec/element/method_missing_spec.rb
opal-jquery-0.0.9 spec/element/method_missing_spec.rb
opal-jquery-0.0.8 spec/element/method_missing_spec.rb
opal-jquery-0.0.7 spec/element/method_missing_spec.rb