Sha256: 21e98ed28271cecc0600bab48658a4445fbfe80fe4f1304378779abb2348ca2e

Contents?: true

Size: 1.32 KB

Versions: 15

Compression:

Stored size: 1.32 KB

Contents

require 'rspec'
require 'hyperion'

describe HyperionResult do
  describe '#to_s' do
    let!(:route) { RestRoute.new(:get, 'http://somesite.org/foo/bar') }

    def make_result(status, code=400)
      HyperionResult.new(route, status, code)
    end

    it 'pretty prints the result' do
      msg = "Success: #{route.to_s}"
      expect(make_result(HyperionStatus::SUCCESS).to_s).to eql msg

      msg = "Timed out: #{route.to_s}"
      expect(make_result(HyperionStatus::TIMED_OUT).to_s).to eql msg

      msg = "No response: #{route.to_s}"
      expect(make_result(HyperionStatus::NO_RESPONSE).to_s).to eql msg

      msg = "Bad route (404): #{route.to_s}"
      expect(make_result(HyperionStatus::BAD_ROUTE, 404).to_s).to eql msg

      msg = "Client error: #{route.to_s}"
      expect(make_result(HyperionStatus::CLIENT_ERROR, 400).to_s).to eql msg

      msg = "Server error: #{route.to_s}"
      expect(make_result(HyperionStatus::SERVER_ERROR, 500).to_s).to eql msg

      msg = "HTTP 432: #{route.to_s}"
      expect(make_result(HyperionStatus::CHECK_CODE, 432).to_s).to eql msg
    end
  end
end

describe ResponseDescriptor do
  include Hyperion::Headers

  describe '#to_s' do
    it 'returns the short mimetype' do
      rd = ResponseDescriptor.new('ttt', 999, :json)
      expect(rd.to_s).to eql short_mimetype(rd)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
hyperion_http-0.6.0 spec/lib/types_spec.rb
hyperion_http-0.5.0 spec/lib/types_spec.rb
hyperion_http-0.3.0 spec/lib/types_spec.rb
hyperion_http-0.2.4 spec/lib/types_spec.rb
hyperion_http-0.2.3 spec/lib/types_spec.rb
hyperion_http-0.2.2 spec/lib/types_spec.rb
hyperion_http-0.2.1 spec/lib/types_spec.rb
hyperion_http-0.1.9 spec/lib/types_spec.rb
hyperion_http-0.1.8 spec/lib/types_spec.rb
hyperion_http-0.1.7 spec/lib/types_spec.rb
hyperion_http-0.1.6 spec/lib/types_spec.rb
hyperion_http-0.1.5 spec/lib/types_spec.rb
hyperion_http-0.1.4 spec/lib/types_spec.rb
hyperion_http-0.1.3 spec/lib/types_spec.rb
hyperion_http-0.1.2 spec/lib/types_spec.rb