Skip to content

Commit

Permalink
Exchange#finished? returns true if no response expected
Browse files Browse the repository at this point in the history
  • Loading branch information
MC-Squared committed Nov 16, 2023
1 parent 4d829a4 commit 3adea50
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ferrum/network/exchange.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def blocked?
# @return [Boolean]
#
def finished?
blocked? || response&.loaded? || !error.nil?
blocked? || response&.loaded? || !error.nil? || !response_expected?
end

#
Expand Down
16 changes: 16 additions & 0 deletions spec/network/exchange_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@

expect(last_exchange.finished?).to be true
end

it "returns true if an error occurred" do
exchange = Ferrum::Network::Exchange.new(page, "1")

expect(exchange.finished?).to be false
exchange.error = Ferrum::Network::Error.new
expect(exchange.finished?).to be true
end

it "returns true for ping requests" do
exchange = Ferrum::Network::Exchange.new(page, "1")
expect(exchange.finished?).to be false

exchange.request = Ferrum::Network::Request.new({"type" => "Ping"})
expect(exchange.finished?).to be true
end
end

describe "#redirect?" do
Expand Down

0 comments on commit 3adea50

Please sign in to comment.