mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add specs for ExampleConditions
This commit is contained in:
parent
d9363fc8a7
commit
db89a99562
2 changed files with 61 additions and 0 deletions
36
spec/example_conditions_spec.cr
Normal file
36
spec/example_conditions_spec.cr
Normal file
|
@ -0,0 +1,36 @@
|
|||
require "./spec_helper"
|
||||
|
||||
describe Spectator::ExampleConditions do
|
||||
{% for condition in %i[pre_condition post_condition] %}
|
||||
describe "#run_{{condition.id}}s" do
|
||||
it "calls a proc" do
|
||||
called = false
|
||||
conditions = new_conditions({{condition.id}}: ->{ called = true; nil })
|
||||
conditions.run_{{condition.id}}s
|
||||
called.should be_true
|
||||
end
|
||||
|
||||
it "calls multiple procs" do
|
||||
call_count = 0
|
||||
conditions = new_conditions({{condition.id}}s: [
|
||||
->{ call_count += 1; nil },
|
||||
->{ call_count += 2; nil },
|
||||
->{ call_count += 3; nil },
|
||||
])
|
||||
conditions.run_{{condition.id}}s
|
||||
call_count.should eq(6)
|
||||
end
|
||||
|
||||
it "calls procs in the correct order" do
|
||||
calls = [] of Symbol
|
||||
conditions = new_conditions({{condition.id}}s: [
|
||||
->{ calls << :a; nil },
|
||||
->{ calls << :b; nil },
|
||||
->{ calls << :c; nil },
|
||||
])
|
||||
conditions.run_{{condition.id}}s
|
||||
calls.should eq(\%i[a b c])
|
||||
end
|
||||
end
|
||||
{% end %}
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue