Sha256: 5cf162b1058ed67789e5df6c83ebddf707a97f1ec8a552319028fb5c0b8aca1e

Contents?: true

Size: 1.12 KB

Versions: 64

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

describe RestClient do

  it "a simple request" do
    body = 'abc'
    stub_request(:get, "www.example.com").to_return(:body => body, :status => 200)
    response = RestClient.get "www.example.com"
    response.code.should eq 200
    response.body.should eq body
  end

  it "a simple request with gzipped content" do
    stub_request(:get, "www.example.com").with(:headers => { 'Accept-Encoding' => 'gzip, deflate' }).to_return(:body => "\037\213\b\b\006'\252H\000\003t\000\313T\317UH\257\312,HM\341\002\000G\242(\r\v\000\000\000", :status => 200,  :headers => { 'Content-Encoding' => 'gzip' } )
    response = RestClient.get "www.example.com"
    response.code.should eq 200
    response.body.should eq "i'm gziped\n"
  end

  it "a 404" do
    body = "Ho hai ! I'm not here !"
    stub_request(:get, "www.example.com").to_return(:body => body, :status => 404)
    begin
      RestClient.get "www.example.com"
      raise
    rescue RestClient::ResourceNotFound => e
      e.http_code.should eq 404
      e.response.code.should eq 404
      e.response.body.should eq body
      e.http_body.should eq body
    end
  end


end

Version data entries

64 entries across 62 versions & 9 rubygems

Version Path
mrcooper-logstash-output-azuresearch-0.2.2 vendor/jruby/2.5.0/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
tdiary-5.0.7 vendor/bundle/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
tdiary-5.0.6 vendor/bundle/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
tdiary-5.0.5 vendor/bundle/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
tdiary-5.0.4 vendor/bundle/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
tdiary-5.0.2 vendor/bundle/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
tdiary-5.0.1 vendor/bundle/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/rest-client-1.8.0/spec/integration/integration_spec.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/rest-client-1.8.0/spec/integration/integration_spec.rb