Sha256: 5318ada83ef33f598573b911792be849a6b98f5f829f41a39a80221c9e8ead6b

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

require 'http/spec_helper'

describe "HTTP basics" do
  inject :environment => :environment,
    :conveyors => :conveyors
  
  with_environment :development
    
  before :all do    
    @dir = File.expand_path(File.dirname(__FILE__))
    @app_original_dir = "#{@dir}/http_spec_data"
    $APP_DIR = "#{@dir}/http_spec"
    
    FileUtils.rm_r $APP_DIR if File.exist? $APP_DIR
    FileUtils.cp_r @app_original_dir, $APP_DIR    
    
    crystal.after :environment do      
      crystal.conveyors.web do |web|
        web.use Crystal::Processors::HttpWriter
        web.use Crystal::Processors::PrepareParams
        web.use Crystal::Processors::EvaluateFormat
      end
    end    
    
    load "#{$APP_DIR}/config/init.rb"        
  end
  
  after :all do
    remove_constants %w(PrepareParamsStub)
    
    $LOAD_PATH.delete "#{$APP_DIR}/plugin_a"
    $LOAD_PATH.delete "#{$APP_DIR}/plugin_b"
    
    FileUtils.rm_r $APP_DIR if File.exist? $APP_DIR
  end
  
  it "public symlink" do
    crystal[:environment]
    crystal.config.environment.should == 'development'
    File.should exist("#{$APP_DIR}/public/plugin_b")
  end
  
  it "http call" do    
    workspace = nil
    Crystal::HTTPAdapter.mock_call do |&block|
      block.call
      workspace = crystal[:workspace]
    end
    # .should == [200, {"Content-Type" => "text/html"}, ""]      
      
    expected_result = {:path => "/", :response => [200, {"Content-Type" => "text/html"}, ""], :params => {"format" => "html"}}
    workspace.to_h.symbolize_keys.subset(expected_result.keys).should == expected_result      
  end
  
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crystal-0.0.13 spec/http/http_spec.rb