Sha256: 8f4c87ac43160dec1e3fdde4ff700eae33ed45311bf8602d9f0ed0bb407603c5

Contents?: true

Size: 745 Bytes

Versions: 7

Compression:

Stored size: 745 Bytes

Contents

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

test "accept mimetypes" do
  Cuba.define do
    on accept("application/xml") do
      res.write res["Content-Type"]
    end
  end

  env = { "HTTP_ACCEPT" => "application/xml", 
          "SCRIPT_NAME" => "/", "PATH_INFO" => "/post" }

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

  assert_equal ["application/xml"], resp.body
end

test "tests don't fail when you don't specify an accept type" do
  Cuba.define do
    on accept("application/xml") do
      res.write res["Content-Type"]
    end

    on default do
      res.write "Default action"
    end
  end

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

  _, _, resp = Cuba.call({})

  assert_equal ["Default action"], resp.body
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cuba-2.2.1 test/accept.rb
cuba-2.2.0 test/accept.rb
cuba-2.2.0.rc1 test/accept.rb
cuba-2.1.0 test/accept.rb
cuba-2.1.0.rc1 test/accept.rb
cuba-2.0.1 test/accept.rb
cuba-2.0.0 test/accept.rb