tonobo / hcloud-ruby

Native ruby client for HetznerCloud
MIT License
32 stars 11 forks source link

[Enhancement] Make Typhoeus call check more natural to read #66

Open ghost opened 1 year ago

ghost commented 1 year ago

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