Sha256: b0b9009588548ba5b9c936ec57e27a774dbb589d25728c51d0bb70ee212165ed

Contents?: true

Size: 995 Bytes

Versions: 13

Compression:

Stored size: 995 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
begin
  require 'yajl/bzip2'
rescue
  warn "Couldn't load yajl/bzip2, maybe you don't have bzip2-ruby installed? Continuing without running bzip2 specs."
end
require 'yajl/gzip'
require 'yajl/deflate'
require 'yajl/http_stream'

describe "Yajl HTTP error" do
  before(:all) do
    @request = File.new(File.expand_path(File.dirname(__FILE__) + "/fixtures/http.error.dump"), 'r')
    @uri = 'file://'+File.expand_path(File.dirname(__FILE__) + "/fixtures/http/http.error.dump")
    TCPSocket.should_receive(:new).and_return(@request)
    @request.should_receive(:write)

    begin
      Yajl::HttpStream.get(@uri)
    rescue Yajl::HttpStream::HttpError => e
      @error = e
    end
  end

  it "should contain the error code in the message" do
    @error.message.should match(/404/)
  end

  it "should provide the HTTP response headers" do
    @error.headers.keys.should include('ETag', 'Content-Length', 'Server')
  end
end

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
yajl-ruby-1.2.3 spec/http/http_error_spec.rb
yajl-ruby-1.2.2 spec/http/http_error_spec.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/yajl-ruby-1.2.1/spec/http/http_error_spec.rb
yajl-ruby-1.2.1 spec/http/http_error_spec.rb
yajl-ruby-1.2.0 spec/http/http_error_spec.rb
yajl-ruby-zenjoy-1.1.0 spec/http/http_error_spec.rb
yajl-ruby-maglev--1.1.0 spec/http/http_error_spec.rb
yajl-ruby-1.1.0-x86-mswin32-60 spec/http/http_error_spec.rb
yajl-ruby-1.1.0-x86-mingw32 spec/http/http_error_spec.rb
yajl-ruby-1.1.0 spec/http/http_error_spec.rb
yajl-ruby-1.0.0-x86-mswin32-60 spec/http/http_error_spec.rb
yajl-ruby-1.0.0-x86-mingw32 spec/http/http_error_spec.rb
yajl-ruby-1.0.0 spec/http/http_error_spec.rb