Sha256: a1bf17e298dbf08516020411a2e1ff13c122524c2582f88520e125d44345b531

Contents?: true

Size: 1.95 KB

Versions: 5

Compression:

Stored size: 1.95 KB

Contents

require 'spec_helper'

describe Restfulie::Client::HTTP do

  context 'RequestHistory' do
  
    before do
      @host = "http://localhost:4567"
    end
  
    it "should remember last requests" do
      r1 = Restfulie.at(@host).history.at('/test').accepts('application/atom+xml').with('Accept-Language' => 'en').get
      r1.should respond_with_status(200)
      r2 = r1.debug.at('/test').accepts('text/html').with('Accept-Language' => 'pt-BR').head
      r2.should respond_with_status(200)
      r3 = r2.at('/test').as('application/xml').with('Accept-Language' => 'en').delete!
      r3.should respond_with_status(200)
      r4 = r3.at('/test/500').accepts('application/xml').with('Accept-Language' => 'en').get
      r4.should respond_with_status(500)
  
      req = r4.debug.history(-4)
      req.get.should respond_with_status(200)
      req.path.should == '/test'
      req.host.to_s.should == @host + "/test"
      req.headers['Accept'].should == 'application/atom+xml'
      req.headers['Accept-Language'].should == 'en'
  
      req = req.history(-4)
      req.head.should respond_with_status(200)
      req.path.should == '/test'
      req.host.to_s.should == @host + "/test"
      req.headers['Accept'].should == 'text/html'
      req.headers['Accept-Language'].should == 'pt-BR'
  
      req = req.history(-4)
      req.post!.should respond_with_status(200)
      req.path.should == '/test'
      req.host.to_s.should == @host + "/test"
      req.headers['Accept'].should == 'application/xml'
      req.headers['Accept-Language'].should == 'en'
      req.headers['Content-Type'].should == 'application/xml'
  
      req = req.history(-4)
      req.get.should respond_with_status(500)
      req.path.should == '/test/500'
      req.host.to_s.should == @host + "/test/500"
      req.headers['Accept'].should == 'application/xml'
      req.headers['Accept-Language'].should == 'en'
  
      lambda { req.history(10).request }.should raise_error RuntimeError
    end 
  
  end
    
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
restfulie-nosqlite-1.0.4 tests/spec/requests/http/history_spec.rb
restfulie-1.1.1 tests/spec/requests/http/history_spec.rb
restfulie-1.1.0 tests/spec/requests/http/history_spec.rb
restfulie-nosqlite-1.0.3 tests/spec/requests/http/history_spec.rb
restfulie-1.0.3 tests/spec/requests/http/history_spec.rb