2021-10-09 19:39:44 +00:00
|
|
|
require "../spec_helper"
|
2021-03-31 21:28:16 +00:00
|
|
|
|
2022-05-25 23:20:57 +00:00
|
|
|
Spectator.describe Spectator, :smoke do
|
2021-03-31 21:28:16 +00:00
|
|
|
let(current_example) { ::Spectator::Example.current }
|
|
|
|
subject(location) { current_example.location }
|
|
|
|
|
|
|
|
context "line numbers" do
|
|
|
|
it "contains starting line of spec" do
|
|
|
|
expect(location.line).to eq(__LINE__ - 1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "contains ending line of spec" do
|
|
|
|
expect(location.end_line).to eq(__LINE__ + 1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "handles multiple lines and examples" do
|
|
|
|
# Offset is important.
|
2021-08-19 19:16:50 +00:00
|
|
|
expect(location.line).to eq(__LINE__ - 2)
|
2021-03-31 21:28:16 +00:00
|
|
|
# This line fails, refer to https://github.com/crystal-lang/crystal/issues/10562
|
|
|
|
# expect(location.end_line).to eq(__LINE__ + 2)
|
|
|
|
# Offset is still important.
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "file names" do
|
|
|
|
subject { location.file }
|
|
|
|
|
|
|
|
it "match source code" do
|
|
|
|
is_expected.to eq(__FILE__)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|