shard-spectator/spec/features/custom_message_spec.cr

32 lines
939 B
Crystal
Raw Normal View History

2021-10-09 19:39:44 +00:00
require "../spec_helper"
2022-05-25 23:20:57 +00:00
Spectator.describe Spectator, :smoke do
it "supports custom expectation messages" do
expect do
expect(false).to be_true, "paradox!"
end.to raise_error(Spectator::ExampleFailed, "paradox!")
end
it "supports custom expectation messages with a proc" do
count = 0
expect do
expect(false).to be_true, ->{ count += 1; "Failed #{count} times" }
end.to raise_error(Spectator::ExampleFailed, "Failed 1 times")
end
context "not_to" do
it "supports custom expectation messages" do
expect do
expect(true).not_to be_true, "paradox!"
end.to raise_error(Spectator::ExampleFailed, "paradox!")
end
it "supports custom expectation messages with a proc" do
count = 0
expect do
expect(true).not_to be_true, ->{ count += 1; "Failed #{count} times" }
end.to raise_error(Spectator::ExampleFailed, "Failed 1 times")
end
end
end