Sha256: 1b34a3165f47adfd3bd7587a7ce50d49b6b817f2c9428b7dee461f7a5e5554ca

Contents?: true

Size: 650 Bytes

Versions: 1

Compression:

Stored size: 650 Bytes

Contents

require File.expand_path("helper", File.dirname(__FILE__))
require 'json'

test "set a block to return json" do
  rum_and_coke = { "rum" => "hot", "coke" => "sweet" }
  Cuba.define do
    on "drinks" do
      as_json 201, {"Content-Location" => "http://somewhere.com/drinks/42"} do
        rum_and_coke
      end
    end
  end

  env = { "SCRIPT_NAME" => "/", "PATH_INFO" => "/drinks" }

  _, _, resp = Cuba.call(env)

  assert_equal 201, resp.status
  assert_equal "application/json", resp.headers["Content-Type"]
  assert_equal [rum_and_coke.to_json], resp.body
  assert_equal "http://somewhere.com/drinks/42", resp.headers["Content-Location"]
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cuba-sugar-0.2.1 test/as_json.rb