Sha256: 25490d463f49a4e4ad61dd75880f67a5626d1e0ee5530516f4c06d6d9513f65f

Contents?: true

Size: 787 Bytes

Versions: 2

Compression:

Stored size: 787 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Hyperdrive::Response do
  before do
    @resource = Hyperdrive::Resource.new(:things)
  end

  it "throws an error when the request method is unspported by hyperdrive" do
    proc { Hyperdrive::Response.new({ 'REQUEST_METHOD' => 'TRACE' }, @resource) }.must_raise Hyperdrive::Errors::NotImplemented
  end

  it "throws an error when the request method is not allowed" do
    proc { Hyperdrive::Response.new({ 'REQUEST_METHOD' => 'GET' }, @resource) }.must_raise Hyperdrive::Errors::MethodNotAllowed
  end

  it "responds to requests" do
    @resource.define_request_handler(:get, Proc.new { return 'ok' })
    response = Hyperdrive::Response.new({ 'REQUEST_METHOD' => 'GET' }, @resource)
    response.response.must_equal 'ok'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hyperdrive-0.0.5 spec/hyperdrive/response_spec.rb
hyperdrive-0.0.4 spec/hyperdrive/response_spec.rb