Sha256: fdc996151ea564c991bc7455efc8db5305d79168880b4998ad6f5b777dbef40c

Contents?: true

Size: 872 Bytes

Versions: 16

Compression:

Stored size: 872 Bytes

Contents

require "spec_helper"

module MethodMissingSpecs
  class A
    def method_missing(mid, *args)
      [mid, args]
    end
  end

  class B
    def method_missing(mid, *args, &block)
      [mid, block]
    end
  end
end

describe "method_missing" do
  before do
    @obj = MethodMissingSpecs::A.new
  end

  it "should pass the missing method name as first argument" do
    @obj.foo.should == [:foo, []]
  end

  it "should correctly pass arguments to method_missing" do
    @obj.bar(1, 2, 3).should == [:bar, [1, 2, 3]]
  end

  it "should pass blocks to method_missing" do
    obj = MethodMissingSpecs::B.new
    proc = proc { 1 }
    obj.baz(1, 2, &proc).should == [:baz, proc]
  end
end

describe "BasicObject#method_missing" do
  it "raises an error for the missing method" do
    lambda {
      BasicObject.new.foo_bar_baz
    }.should raise_error(Exception)
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
opal-0.6.3 spec/opal/core/runtime/method_missing_spec.rb
opal-0.6.2 spec/opal/core/runtime/method_missing_spec.rb
opal-0.6.1 spec/opal/core/runtime/method_missing_spec.rb
opal-0.6.0 spec/opal/core/runtime/method_missing_spec.rb
opal-0.5.5 spec/opal/core/runtime/method_missing_spec.rb
opal-0.5.4 spec/corelib/runtime/method_missing_spec.rb
opal-0.5.2 spec/corelib/runtime/method_missing_spec.rb
opal-0.5.0 spec/corelib/runtime/method_missing_spec.rb
opal-0.4.4 spec/opal/method_missing_spec.rb
opal-0.4.3 spec/opal/method_missing_spec.rb
opal-0.4.2 spec/opal/method_missing_spec.rb
opal-0.4.1 spec/opal/method_missing_spec.rb
opal-0.4.0 spec/opal/method_missing_spec.rb
opal-0.3.44 spec/opal/method_missing_spec.rb
opal-0.3.43 spec/opal/method_missing_spec.rb
opal-0.3.42 spec/core_ext/method_missing_spec.rb