2013-07-28 19:03:06 -04:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2012-08-19 15:25:11 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2013-12-29 16:50:24 -05:00
|
|
|
describe Mutant::Loader::Eval, '.call' do
|
2012-11-21 14:31:01 -05:00
|
|
|
|
2013-12-29 16:50:24 -05:00
|
|
|
subject { object.call(node, mutation_subject) }
|
2012-08-19 15:25:11 -04:00
|
|
|
|
2013-07-29 20:33:44 -04:00
|
|
|
let(:object) { described_class }
|
|
|
|
let(:path) { __FILE__ }
|
|
|
|
let(:line) { 1 }
|
2013-07-28 17:52:05 -04:00
|
|
|
|
|
|
|
let(:mutation_subject) do
|
2013-09-08 16:12:23 -04:00
|
|
|
double('Subject', source_path: path, source_line: line)
|
2013-07-28 17:52:05 -04:00
|
|
|
end
|
2012-08-19 15:25:11 -04:00
|
|
|
|
|
|
|
let(:source) do
|
|
|
|
<<-RUBY
|
|
|
|
class SomeNamespace
|
|
|
|
class Bar
|
2012-12-14 13:53:37 -05:00
|
|
|
def some_method
|
|
|
|
end
|
2012-08-19 15:25:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class SomeOther
|
|
|
|
class Foo < Bar
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
RUBY
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:node) do
|
2013-06-04 13:22:33 -04:00
|
|
|
parse(source)
|
2012-08-19 15:25:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should load nodes into vm' do
|
|
|
|
subject
|
2012-11-21 14:31:01 -05:00
|
|
|
::SomeNamespace::SomeOther::Foo
|
2012-08-19 15:25:11 -04:00
|
|
|
end
|
2012-12-14 13:53:37 -05:00
|
|
|
|
|
|
|
it 'should set file and line correctly' do
|
|
|
|
subject
|
2014-01-19 15:42:21 -05:00
|
|
|
expect(::SomeNamespace::Bar
|
2013-07-28 17:52:05 -04:00
|
|
|
.instance_method(:some_method)
|
2014-01-19 15:42:21 -05:00
|
|
|
.source_location).to eql([__FILE__, 3])
|
2012-12-14 13:53:37 -05:00
|
|
|
end
|
2012-08-19 15:25:11 -04:00
|
|
|
end
|