mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Initial code to get match data values to output
Expose the match data values through the Expectation class.
This commit is contained in:
parent
0a48b5f447
commit
4e3290ebfe
3 changed files with 24 additions and 2 deletions
|
@ -41,6 +41,15 @@ describe Spectator::Expectations::Expectation do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#values" do
|
||||||
|
it "is the same as the match data values" do
|
||||||
|
value = 42
|
||||||
|
match_data = new_matcher(value).match(new_partial(value))
|
||||||
|
expectation = Spectator::Expectations::Expectation.new(match_data, false)
|
||||||
|
expectation.values.should eq(match_data.values)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#actual_message" do
|
describe "#actual_message" do
|
||||||
context "with a successful match" do
|
context "with a successful match" do
|
||||||
it "equals the matcher's #message" do
|
it "equals the matcher's #message" do
|
||||||
|
|
|
@ -18,6 +18,12 @@ module Spectator::Expectations
|
||||||
@match_data.matched? ^ @negated
|
@match_data.matched? ^ @negated
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Information about the match.
|
||||||
|
# Returned value and type will something that has key-value pairs (like a `NamedTuple`).
|
||||||
|
def values
|
||||||
|
@match_data.values
|
||||||
|
end
|
||||||
|
|
||||||
# Text that indicates the condition that must be met for the expectation to be satisifed.
|
# Text that indicates the condition that must be met for the expectation to be satisifed.
|
||||||
def expected_message
|
def expected_message
|
||||||
@negated ? @match_data.negated_message : @match_data.message
|
@negated ? @match_data.negated_message : @match_data.message
|
||||||
|
|
|
@ -61,8 +61,15 @@ module Spectator::Formatters
|
||||||
private def values(io)
|
private def values(io)
|
||||||
io.puts
|
io.puts
|
||||||
indent do
|
indent do
|
||||||
line(io) { io << "Expected: TODO" }
|
@result.expectations.each_unsatisfied do |expectation|
|
||||||
line(io) { io << " got: TODO" }
|
expectation.values.each do |key, value|
|
||||||
|
line(io) do
|
||||||
|
io << key
|
||||||
|
io << ": "
|
||||||
|
io << value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
io.puts
|
io.puts
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue