Sha256: 178bae87970dc00f400dc49cb27ba12c847ffe2671480a3c5452cfc11adb2706

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

ENV['VITREOUS_FOLDER'] = File.expand_path "#{File.dirname(__FILE__)}/fixtures/vitreous_folder"
ENV['RACK_ENV'] = 'test'

require File.expand_path "#{File.dirname(__FILE__)}/../lib/vitreous_standalone.rb"
require 'rack/test'
require 'test/unit'
require 'mocha'

FIXTURES_PATH = "#{File.dirname(__FILE__)}/fixtures"

class VitreousStandaloneTest < Test::Unit::TestCase
  include Rack::Test::Methods

  def app
    Vitreous::Standalone::App.new
  end
  
  def test_show_root
    get '/'
    assert_equal File.read( "#{FIXTURES_PATH}/responses/show.txt" ), last_response.body
    assert_equal 200, last_response.status
  end
  
  def test_show_collection
    get '/folder'
    assert_equal File.read( "#{FIXTURES_PATH}/responses/collection.txt" ), last_response.body
    assert_equal 200, last_response.status
  end
  
  def test_show_element
    get '/folder/file'
    assert_equal File.read( "#{FIXTURES_PATH}/responses/element.txt" ), last_response.body
    assert_equal 200, last_response.status
  end
  
  def test_404
    get '/not_exists'
    assert_equal 404, last_response.status
  end
  
  def test_assets
    get '/assets/nyc.png'
    assert_equal 'image/png', last_response.content_type
    assert_equal 3728, last_response.content_length
  end
  
  def test_file
    get "#{Vitreous::Share::LocalStructure.base_uri}/folder/file.jpg"
    assert_equal 'image/jpeg', last_response.content_type
    assert_equal 750, last_response.content_length
  end
  
  def test_structure
    get '/structure'
    assert_equal 'application/json', last_response.content_type
    assert_equal 909, last_response.content_length
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vitreous_standalone-0.0.17 test/vitreous_standalone_test.rb