Sha256: c769044de5f5fc5bc4dafe3596b2a20448515a0d51b8e779b9f10a880d9572b0
Contents?: true
Size: 1.1 KB
Versions: 9
Compression:
Stored size: 1.1 KB
Contents
require 'rest-core/test' describe RC::ErrorHandler do client = RC::Builder.client do use RC::ErrorHandler run RC::Dry end exp = Class.new(Exception) describe 'there is an exception' do should 'raise an error with future' do lambda{ client.new.get('/', {}, RC::FAIL => [exp.new('fail')]) }.should.raise(exp) end should 'give an error with callback' do client.new.get('/', {}, RC::FAIL => [exp.new('fail')]){ |res| res.should.kind_of?(exp) } end end describe 'error_handler gives an exception' do should 'raise an error with future' do lambda{ client.new(:error_handler => lambda{ |res| exp.new }). get('/', {}, RC::FAIL => [true]) }.should.raise(exp) end should 'give an error with callback' do client.new(:error_handler => lambda{ |res| exp.new }). get('/', {}, RC::FAIL => [true]){ |res| res.should.kind_of?(exp) } end end should 'no exception but errors' do client.new(:error_handler => lambda{ |res| 1 }). request({RC::FAIL => [0]}, RC::FAIL).should.eq [0, 1] end end
Version data entries
9 entries across 9 versions & 1 rubygems