Sha256: 38bf1804c5a198c28a1d90dbeb4b4e3ee417c037b4b2a898988e58f12e9ab12e

Contents?: true

Size: 664 Bytes

Versions: 4

Compression:

Stored size: 664 Bytes

Contents

require 'spec_helper'

describe "Module#define_method" do
  describe "when passed an UnboundMethod object" do
    it "defines a method taking a block" do
      klass = Class.new do
        def foo = yield :bar
      end
      klass.define_method(:baz, klass.instance_method(:foo))
      klass.new.baz { |a| a }.should == :bar
    end
  end

  describe "when called inside a def" do
    it "returns correctly" do
      klass = Class.new do
        def self.my_method_definer
          define_method(:a) do
            return :foo
            :bar
          end
        end
      end

      klass.my_method_definer
      klass.new.a.should == :foo
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
opal-1.8.3.rc1 spec/opal/core/module/define_method_spec.rb
opal-1.8.2 spec/opal/core/module/define_method_spec.rb
opal-1.8.1 spec/opal/core/module/define_method_spec.rb
opal-1.8.0 spec/opal/core/module/define_method_spec.rb