Add Subject#source_lines
This commit is contained in:
parent
a0ef6ed40a
commit
6f30dbcb39
2 changed files with 30 additions and 3 deletions
|
@ -56,6 +56,18 @@ module Mutant
|
|||
self
|
||||
end
|
||||
|
||||
# Return source lines
|
||||
#
|
||||
# @return [Range<Fixnum>]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def source_lines
|
||||
expression = node.location.expression
|
||||
expression.line..expression.source_buffer.decompose_position(expression.end_pos).first
|
||||
end
|
||||
memoize :source_lines
|
||||
|
||||
# Return source line
|
||||
#
|
||||
# @return [Fixnum]
|
||||
|
@ -63,7 +75,7 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def source_line
|
||||
node.location.expression.line
|
||||
source_lines.begin
|
||||
end
|
||||
|
||||
# Return subject identification
|
||||
|
|
|
@ -16,7 +16,10 @@ RSpec.describe Mutant::Subject do
|
|||
let(:config) { Mutant::Config::DEFAULT }
|
||||
|
||||
let(:node) do
|
||||
double('Node', location: location)
|
||||
Parser::CurrentRuby.parse(<<-RUBY)
|
||||
def foo
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
|
||||
let(:location) do
|
||||
|
@ -38,7 +41,19 @@ RSpec.describe Mutant::Subject do
|
|||
describe '#identification' do
|
||||
subject { object.identification }
|
||||
|
||||
it { should eql('SubjectA:source_path:source_line') }
|
||||
it { should eql('SubjectA:source_path:1') }
|
||||
end
|
||||
|
||||
describe '#source_line' do
|
||||
subject { object.source_line }
|
||||
|
||||
it { should be(1) }
|
||||
end
|
||||
|
||||
describe '#source_lines' do
|
||||
subject { object.source_lines }
|
||||
|
||||
it { should eql(1..2) }
|
||||
end
|
||||
|
||||
describe '#prepare' do
|
||||
|
|
Loading…
Add table
Reference in a new issue