Sha256: 373416b2827e178826cb475726bd24fb951c2ea9de9b42eb5b13620a90a0c45e

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

require 'commute/core/http'

describe Commute::Http::Status do

  Status = Commute::Http::Status

  it 'should be a failure for 4xx and 5xx status codes' do
    Status.new(420).fail?.must_equal true
    Status.new(501).fail?.must_equal true
    Status.new(501).success?.must_equal false
  end

  it 'should be a success otherwise' do
    Status.new(200).success?.must_equal true
    Status.new(200).fail?.must_equal false
    Status.new(301).success?.must_equal true
  end
end

describe Commute::Http::Request do

  it 'should have some default values' do
    request = Commute::Http::Request.new nil
    request.uri.path.must_equal '/'
    request.headers.must_be_empty
    request.query.must_be_empty
    request.method.must_equal :get
  end

  it 'should keep uri#query consistent' do
    request = Commute::Http::Request.new nil
    request.query[:limit] = 10
    request.uri.query.must_equal 'limit%3D10'
    request.query[:index] = 20
    request.uri.query.must_equal 'limit%3D10%26index%3D20'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
commute-0.3.0.pre.2 spec/commute/core/http_spec.rb
commute-0.3.0.pre spec/commute/core/http_spec.rb