Sha256: d2d7bb73cb976b4ecc547fb649a48afc5c68e9b14f24fe01dbbb2ba478902752
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
require 'spec_helper' require 'method_log/source_file' require 'method_log/method_finder' describe MethodLog::MethodFinder do it 'finds definition of instance method on class' do foo = MethodLog::SourceFile.new(path: 'foo.rb', source: %{ class Foo def bar # implementation end end }.strip) method_finder = MethodLog::MethodFinder.new(source_file: foo) method_definition = method_finder.find('Foo#bar') expect(method_definition).to eq(MethodLog::MethodDefinition.new(source_file: foo, lines: 1..3)) end it 'finds definition of instance method on module' do foo = MethodLog::SourceFile.new(path: 'foo.rb', source: %{ module Foo def bar # implementation end end }.strip) method_finder = MethodLog::MethodFinder.new(source_file: foo) method_definition = method_finder.find('Foo#bar') expect(method_definition).to eq(MethodLog::MethodDefinition.new(source_file: foo, lines: 1..3)) end it 'finds definition of instance method on class within module' do foo = MethodLog::SourceFile.new(path: 'foo.rb', source: %{ module Foo class Bar def baz # implementation end end end }.strip) method_finder = MethodLog::MethodFinder.new(source_file: foo) method_definition = method_finder.find('Foo::Bar#baz') expect(method_definition).to eq(MethodLog::MethodDefinition.new(source_file: foo, lines: 2..4)) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
method_log-0.0.2 | spec/method_finder_spec.rb |
method_log-0.0.1 | spec/method_finder_spec.rb |