Skip to content

Instantly share code, notes, and snippets.

@rdammkoehler
Created January 8, 2016 19:46
Show Gist options
  • Save rdammkoehler/4eed196feda27a2ed924 to your computer and use it in GitHub Desktop.
Save rdammkoehler/4eed196feda27a2ed924 to your computer and use it in GitHub Desktop.
Sneaky Gimme Tricks
let(:factory) { gimme(ServiceLoaderFactory) }
let(:uri) { 'endpoint' }
# ...
it 'handles both failure and success appropriately' do
@idx = 0
give(factory).create {
@idx += 1
[ Proc.new { fail 'massively' }, Proc.new { } ][@idx-1].call
}
main.run [uri], 2
expect(File.read('factory.log')).to include 'WARN -- : massively (RuntimeError)'
expect(File.read('factory.log')).to include "WARN -- : attempt 1 of 2; #{uri}"
expect(File.read('factory.log')).to include "INFO -- : success get_pages #{uri}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment