From 2895bb245fd216be96da6e4d6b9e361248934450 Mon Sep 17 00:00:00 2001 From: John Mair Date: Fri, 17 Dec 2010 02:58:01 +1300 Subject: first commit --- test/test.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/test.rb (limited to 'test') diff --git a/test/test.rb b/test/test.rb new file mode 100644 index 0000000..8a4beaa --- /dev/null +++ b/test/test.rb @@ -0,0 +1,32 @@ +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 + -- cgit v1.2.1