Merge branch 'master' into release/0.10

This commit is contained in:
Michael Miller 2021-03-31 15:19:30 -06:00
commit 3d702f9bc6
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD
6 changed files with 57 additions and 7 deletions

View file

@ -47,7 +47,7 @@ module Spectator::DSL
::Spectator::DSL::Builder.add_example(
_spectator_example_name(\{{what}}),
::Spectator::Source.new(\{{block.filename}}, \{{block.line_number}}),
::Spectator::Source.new(\{{block.filename}}, \{{block.line_number}}, \{{block.end_line_number}}),
new.as(::Spectator::Context),
\%tags
) do |example|

View file

@ -7,7 +7,9 @@ module Spectator
# Checks whether the example satisfies the filter.
def includes?(example) : Bool
@line == example.source.line
start_line = example.source.line
end_line = example.source.end_line
(start_line..end_line).covers?(@line)
end
end
end

View file

@ -6,11 +6,17 @@ module Spectator
# Absolute file path.
getter file : String
# Line number in the file.
# Starting line number in the file.
getter line : Int32
# Ending line number in the file.
getter end_line : Int32
# Creates the source.
def initialize(@file, @line)
def initialize(@file, @line, end_line = nil)
# if an end line is not provided,
# make the end line the same as the start line
@end_line = end_line || @line
end
# Parses a source from a string.