Sha256: 61c19d0704d575548b4ae9cd1f03153192cb96657cff0240ac188ee6a3bb77e0

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

describe UnderOS::HTTP::Request do
  before do
    @url     = "http://test.com"
    @request = UnderOS::HTTP::Request.new(@url, {
      headers: {my: 'headers'},
      cookies: {my: 'cookies'},
      params:  {my: 'params'},
      method:  :put
    })
  end

  describe "#constructor" do
    it "assigns the url correctly" do
      @request.url.should == @url
    end

    it "assigns the request headers correctly" do
      @request.headers.should == {my: 'headers'}
    end

    it "assigns the request cookies correctly" do
      @request.cookies.should == {my: 'cookies'}
    end

    it "assigns my params correctly" do
      @request.params.should == {my: 'params'}
    end

    it "assigns the request method correctly" do
      @request.method.should == 'PUT'
    end
  end

  describe "#on" do
    it "returns the response object instead of an event into a callback" do
      @response = nil

      @request.on(:smth) { |r| @response = r }
      @request.emit(:smth, response: 'response')

      @response.should == 'response'
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
under-os-http-1.4.0 spec/under_os/http/request_spec.rb
under-os-1.3.0 spec/lib/under_os/http/request_spec.rb
under-os-1.2.1 spec/lib/under_os/http/request_spec.rb
under-os-1.2.0 spec/lib/under_os/http/request_spec.rb
under-os-1.1.0 spec/lib/under_os/http/request_spec.rb