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"
|
||||
end
|
||||
|
||||
# Dummy source file.
|
||||
def source_file
|
||||
__FILE__
|
||||
end
|
||||
|
||||
# Dummy source line number.
|
||||
def source_line
|
||||
__LINE__
|
||||
# Dummy source.
|
||||
def source
|
||||
::Spectator::Source.new(__FILE__, __LINE__)
|
||||
end
|
||||
|
||||
# Dummy instance.
|
||||
|
|
|
@ -5,14 +5,9 @@ class FailingExample < Spectator::RunnableExample
|
|||
"FAIL"
|
||||
end
|
||||
|
||||
# Dummy source file.
|
||||
def source_file
|
||||
__FILE__
|
||||
end
|
||||
|
||||
# Dummy source line number.
|
||||
def source_line
|
||||
__LINE__
|
||||
# Dummy source.
|
||||
def source
|
||||
::Spectator::Source.new(__FILE__, __LINE__)
|
||||
end
|
||||
|
||||
# Dummy instance.
|
||||
|
|
|
@ -5,14 +5,9 @@ class PassingExample < Spectator::RunnableExample
|
|||
"PASS"
|
||||
end
|
||||
|
||||
# Dummy source file.
|
||||
def source_file
|
||||
__FILE__
|
||||
end
|
||||
|
||||
# Dummy source line number.
|
||||
def source_line
|
||||
__LINE__
|
||||
# Dummy source.
|
||||
def source
|
||||
::Spectator::Source.new(__FILE__, __LINE__)
|
||||
end
|
||||
|
||||
# Dummy instance.
|
||||
|
|
|
@ -6,14 +6,9 @@ class SpyExample < Spectator::RunnableExample
|
|||
"SPY"
|
||||
end
|
||||
|
||||
# Dummy source file.
|
||||
def source_file
|
||||
__FILE__
|
||||
end
|
||||
|
||||
# Dummy source line number.
|
||||
def source_line
|
||||
__LINE__
|
||||
# Dummy source.
|
||||
def source
|
||||
::Spectator::Source.new(__FILE__, __LINE__)
|
||||
end
|
||||
|
||||
# Dummy instance.
|
||||
|
|
|
@ -5,12 +5,8 @@ class ConcretePendingExample < Spectator::PendingExample
|
|||
"PENDING_TEST_EXAMPLE"
|
||||
end
|
||||
|
||||
def source_file
|
||||
__FILE__
|
||||
end
|
||||
|
||||
def source_line
|
||||
__LINE__
|
||||
def source
|
||||
::Spectator::Source.new(__FILE__, __LINE__)
|
||||
end
|
||||
|
||||
def instance
|
||||
|
|
|
@ -1354,14 +1354,9 @@ module Spectator::DSL
|
|||
|
||||
# Create a class derived from `RunnableExample` to run the test code.
|
||||
_spectator_example(Example%example, Test%example, ::Spectator::RunnableExample, {{what}}) do
|
||||
# Source file the example originated from.
|
||||
def source_file
|
||||
{{_source_file}}
|
||||
end
|
||||
|
||||
# Line number in the source file the example originated from.
|
||||
def source_line
|
||||
{{_source_line}}
|
||||
# Source where the example originated from.
|
||||
def source
|
||||
::Spectator::Source.new({{_source_file}}, {{_source_line}})
|
||||
end
|
||||
|
||||
# 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.
|
||||
_spectator_example(Example%example, Test%example, ::Spectator::PendingExample, {{what}}) do
|
||||
# Source file the example originated from.
|
||||
def source_file
|
||||
{{_source_file}}
|
||||
end
|
||||
|
||||
# Line number in the source file the example originated from.
|
||||
def source_line
|
||||
{{_source_line}}
|
||||
# Source where the example originated from.
|
||||
def source
|
||||
::Spectator::Source.new({{_source_file}}, {{_source_line}})
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -14,14 +14,9 @@ module Spectator
|
|||
"DUMMY"
|
||||
end
|
||||
|
||||
# Dummy source file.
|
||||
def source_file
|
||||
__FILE__
|
||||
end
|
||||
|
||||
# Dummy source line number.
|
||||
def source_line
|
||||
__LINE__
|
||||
# Dummy source.
|
||||
def source
|
||||
Source.new(__FILE__, __LINE__)
|
||||
end
|
||||
|
||||
# Dummy instance.
|
||||
|
|
|
@ -13,11 +13,8 @@ module Spectator
|
|||
# Retrieves the internal wrapped instance.
|
||||
abstract def instance
|
||||
|
||||
# Source file the example originated from.
|
||||
abstract def source_file : String
|
||||
|
||||
# Line number in the source file the example originated from.
|
||||
abstract def source_line : Int64
|
||||
# Source where the example originated from.
|
||||
abstract def source : Source
|
||||
|
||||
# Runs the example code.
|
||||
# A result is returned, which represents the outcome of the test.
|
||||
|
|
|
@ -4,9 +4,7 @@ module Spectator::Formatters
|
|||
end
|
||||
|
||||
def source(io)
|
||||
io << @result.example.source_file
|
||||
io << ':'
|
||||
io << @result.example.source_line
|
||||
@result.example.source.to_s(io)
|
||||
end
|
||||
|
||||
def to_s(io)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue