Sha256: d53a7eeee7c25b9fc24dd5349c687515221e41a972fdedba1f75fb4846c8d4c9

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

require "test/helper"
require 'rack/less/response'

class RequestTest < Test::Unit::TestCase

  context 'Rack::Less::Response' do
    setup do
      @defaults = env_defaults
      @css = File.read(file_path('test','fixtures','sinatra','app','stylesheets', 'css_compiled.css'))
      @response = less_response(@css)
    end

    should "have some attributes" do
      [ :options,
        :status,
        :headers,
        :body,
        :content_length,
        :content_type,
        :to_rack
      ].each do |a|
        assert_respond_to @response, a, "request does not respond to #{a.inspect}"
      end
    end

    should "set it's status to '#{Rack::Utils::HTTP_STATUS_CODES[200]}'" do
      assert_equal 200, @response.status
    end

    should "set it's Content-Type to '#{Rack::Less::MIME_TYPE}'" do
      assert_equal Rack::Less::MIME_TYPE, @response.content_type, 'the content_type accessor is incorrect'
      assert_equal Rack::Less::MIME_TYPE, @response.headers['Content-Type'], 'the Content-Type header is incorrect'
    end

    should "set it's Content-Length appropriately" do
      assert_equal Rack::Less::Response.content_length(@css), @response.content_length, 'the content_length accessor is incorrect'
      assert_equal Rack::Less::Response.content_length(@css), @response.headers['Content-Length'].to_i
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rack-less-2.0.2 test/response_test.rb
rack-less-2.0.1 test/response_test.rb
rack-less-2.0.0 test/response_test.rb