mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Replace source file and line with source struct
This commit is contained in:
parent
ffca0316a4
commit
ed01a95e67
9 changed files with 26 additions and 70 deletions
|
@ -5,14 +5,9 @@ class ErroredExample < Spectator::RunnableExample
|
||||||
"ERROR"
|
"ERROR"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy source file.
|
# Dummy source.
|
||||||
def source_file
|
def source
|
||||||
__FILE__
|
::Spectator::Source.new(__FILE__, __LINE__)
|
||||||
end
|
|
||||||
|
|
||||||
# Dummy source line number.
|
|
||||||
def source_line
|
|
||||||
__LINE__
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy instance.
|
# Dummy instance.
|
||||||
|
|
|
@ -5,14 +5,9 @@ class FailingExample < Spectator::RunnableExample
|
||||||
"FAIL"
|
"FAIL"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy source file.
|
# Dummy source.
|
||||||
def source_file
|
def source
|
||||||
__FILE__
|
::Spectator::Source.new(__FILE__, __LINE__)
|
||||||
end
|
|
||||||
|
|
||||||
# Dummy source line number.
|
|
||||||
def source_line
|
|
||||||
__LINE__
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy instance.
|
# Dummy instance.
|
||||||
|
|
|
@ -5,14 +5,9 @@ class PassingExample < Spectator::RunnableExample
|
||||||
"PASS"
|
"PASS"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy source file.
|
# Dummy source.
|
||||||
def source_file
|
def source
|
||||||
__FILE__
|
::Spectator::Source.new(__FILE__, __LINE__)
|
||||||
end
|
|
||||||
|
|
||||||
# Dummy source line number.
|
|
||||||
def source_line
|
|
||||||
__LINE__
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy instance.
|
# Dummy instance.
|
||||||
|
|
|
@ -6,14 +6,9 @@ class SpyExample < Spectator::RunnableExample
|
||||||
"SPY"
|
"SPY"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy source file.
|
# Dummy source.
|
||||||
def source_file
|
def source
|
||||||
__FILE__
|
::Spectator::Source.new(__FILE__, __LINE__)
|
||||||
end
|
|
||||||
|
|
||||||
# Dummy source line number.
|
|
||||||
def source_line
|
|
||||||
__LINE__
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy instance.
|
# Dummy instance.
|
||||||
|
|
|
@ -5,12 +5,8 @@ class ConcretePendingExample < Spectator::PendingExample
|
||||||
"PENDING_TEST_EXAMPLE"
|
"PENDING_TEST_EXAMPLE"
|
||||||
end
|
end
|
||||||
|
|
||||||
def source_file
|
def source
|
||||||
__FILE__
|
::Spectator::Source.new(__FILE__, __LINE__)
|
||||||
end
|
|
||||||
|
|
||||||
def source_line
|
|
||||||
__LINE__
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def instance
|
def instance
|
||||||
|
|
|
@ -1354,14 +1354,9 @@ module Spectator::DSL
|
||||||
|
|
||||||
# Create a class derived from `RunnableExample` to run the test code.
|
# Create a class derived from `RunnableExample` to run the test code.
|
||||||
_spectator_example(Example%example, Test%example, ::Spectator::RunnableExample, {{what}}) do
|
_spectator_example(Example%example, Test%example, ::Spectator::RunnableExample, {{what}}) do
|
||||||
# Source file the example originated from.
|
# Source where the example originated from.
|
||||||
def source_file
|
def source
|
||||||
{{_source_file}}
|
::Spectator::Source.new({{_source_file}}, {{_source_line}})
|
||||||
end
|
|
||||||
|
|
||||||
# Line number in the source file the example originated from.
|
|
||||||
def source_line
|
|
||||||
{{_source_line}}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Implement abstract method to run the wrapped example block.
|
# Implement abstract method to run the wrapped example block.
|
||||||
|
@ -1408,14 +1403,9 @@ module Spectator::DSL
|
||||||
|
|
||||||
# Create a class derived from `PendingExample` to skip the test code.
|
# Create a class derived from `PendingExample` to skip the test code.
|
||||||
_spectator_example(Example%example, Test%example, ::Spectator::PendingExample, {{what}}) do
|
_spectator_example(Example%example, Test%example, ::Spectator::PendingExample, {{what}}) do
|
||||||
# Source file the example originated from.
|
# Source where the example originated from.
|
||||||
def source_file
|
def source
|
||||||
{{_source_file}}
|
::Spectator::Source.new({{_source_file}}, {{_source_line}})
|
||||||
end
|
|
||||||
|
|
||||||
# Line number in the source file the example originated from.
|
|
||||||
def source_line
|
|
||||||
{{_source_line}}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,14 +14,9 @@ module Spectator
|
||||||
"DUMMY"
|
"DUMMY"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy source file.
|
# Dummy source.
|
||||||
def source_file
|
def source
|
||||||
__FILE__
|
Source.new(__FILE__, __LINE__)
|
||||||
end
|
|
||||||
|
|
||||||
# Dummy source line number.
|
|
||||||
def source_line
|
|
||||||
__LINE__
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy instance.
|
# Dummy instance.
|
||||||
|
|
|
@ -13,11 +13,8 @@ module Spectator
|
||||||
# Retrieves the internal wrapped instance.
|
# Retrieves the internal wrapped instance.
|
||||||
abstract def instance
|
abstract def instance
|
||||||
|
|
||||||
# Source file the example originated from.
|
# Source where the example originated from.
|
||||||
abstract def source_file : String
|
abstract def source : Source
|
||||||
|
|
||||||
# Line number in the source file the example originated from.
|
|
||||||
abstract def source_line : Int64
|
|
||||||
|
|
||||||
# Runs the example code.
|
# Runs the example code.
|
||||||
# A result is returned, which represents the outcome of the test.
|
# A result is returned, which represents the outcome of the test.
|
||||||
|
|
|
@ -4,9 +4,7 @@ module Spectator::Formatters
|
||||||
end
|
end
|
||||||
|
|
||||||
def source(io)
|
def source(io)
|
||||||
io << @result.example.source_file
|
@result.example.source.to_s(io)
|
||||||
io << ':'
|
|
||||||
io << @result.example.source_line
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(io)
|
def to_s(io)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue