Skip to content

Commit

Permalink
Refactor expectations with SpecChannelStatus to be explicit
Browse files Browse the repository at this point in the history
Comparing against the expected value offers better information when the
spec fails because it shows the actual value, instead of true/fals for a
predicate method.
  • Loading branch information
straight-shoota committed Mar 20, 2024
1 parent 2f143fb commit 02b57ef
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion spec/std/http/server/server_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe HTTP::Server do
sleep 0.1
server.close

ch.receive.end?.should be_true
ch.receive.should eq SpecChannelStatus::End
end

it "reuses the TCP port (SO_REUSEPORT)" do
Expand Down
8 changes: 4 additions & 4 deletions spec/std/io/io_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -973,11 +973,11 @@ describe IO do

schedule_timeout ch

ch.receive.begin?.should be_true
ch.receive.should eq SpecChannelStatus::Begin
wait_until_blocked f

read.close
ch.receive.end?.should be_true
ch.receive.should eq SpecChannelStatus::End
end
end

Expand All @@ -996,11 +996,11 @@ describe IO do

schedule_timeout ch

ch.receive.begin?.should be_true
ch.receive.should eq SpecChannelStatus::Begin
wait_until_blocked f

write.close
ch.receive.end?.should be_true
ch.receive.should eq SpecChannelStatus::End
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/std/socket/unix_server_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ describe UNIXServer do
ch.send(:end)
end

ch.receive.begin?.should be_true
ch.receive.should eq SpecChannelStatus::Begin

# wait for the server to call accept
wait_until_blocked f

server.close
ch.receive.end?.should be_true
ch.receive.should eq SpecChannelStatus::End

exception.should be_a(IO::Error)
exception.try(&.message).should eq("Closed stream")
Expand Down Expand Up @@ -136,13 +136,13 @@ describe UNIXServer do
ch.send :end
end

ch.receive.begin?.should be_true
ch.receive.should eq SpecChannelStatus::Begin

# wait for the server to call accept
wait_until_blocked f

server.close
ch.receive.end?.should be_true
ch.receive.should eq SpecChannelStatus::End

ret.should be_nil
end
Expand Down

0 comments on commit 02b57ef

Please sign in to comment.