Sha256: cd4429afa1ed5c9ab4a7a1f999b00e336c46c946e94ff3fca71e9b9214f79bbb

Contents?: true

Size: 767 Bytes

Versions: 1

Compression:

Stored size: 767 Bytes

Contents

direc = File.dirname(__FILE__)

require 'bacon'
require "#{direc}/../lib/method_source"

hello_source = "def hello; :hello; end\n"

def hello; :hello; end

describe MethodSource do

  it 'should define methods on both Method and UnboundMethod' do
    Method.method_defined?(:source).should == true
    UnboundMethod.method_defined?(:source).should == true
  end
  
  if RUBY_VERSION =~ /1.9/
    it 'should return source for method' do
      method(:hello).source.should == hello_source
    end

    it 'should raise for C methods' do
      lambda { method(:puts).source }.should.raise RuntimeError
    end

  else
    it 'should raise on #source' do
      lambda { method(:hello).source }.should.raise RuntimeError
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
method_source-0.1.0 test/test.rb