hcloud-ruby
hcloud-ruby copied to clipboard
[Enhancement] Make Typhoeus call check more natural to read
Rspec tests usually follow a human-readable schema that's almost an English sentence.
We currently check whether a Typhoeus stub was called with expect(stub.times_called).to eq(1)
. Side note: times_called
uses Typhoeus private data.
Rspec, at least for yield_control
, has expect { ... }.to yield_control.twice
and similar tests. Following the same design as yield_control
we could implement the following have_been_called
matcher:
expect(stub).to have_been_called
expect(stub).to have_been_called.once
expect(stub).to have_been_called.exactly(k).times
expect(stub).to have_been_called.at_most(k).times
expect(stub).to have_been_called.at_least(k).times