Sha256: 8ff7c1a80276b127baf3a01720c025f91f8edb9d3a79239f3e21f59991235b0d

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require 'http/spec_helper'

describe "HTTP basics" do
  inject environment: :environment, conveyors: :conveyors
  
  the_spec_dir = with_tmp_spec_dir
  with_environment environment: :development, runtime_dir: "#{the_spec_dir}/app/runtime"
  
  with_load_path(
    "#{the_spec_dir}/app/lib",
    "#{the_spec_dir}/plugin_a/lib",
    "#{the_spec_dir}/plugin_b/lib",
  )
    
  before :all do    
    rad.after :environment do      
      rad.conveyors.web do |web|
        web.use Rad::Processors::HttpWriter
        web.use Rad::Processors::PrepareParams
        web.use Rad::Processors::EvaluateFormat
      end
    end
  end
  
  after :all do
    remove_constants %w(PrepareParamsStub)
  end
  
  before :each do
    load "app/init.rb"
  end
  
  it "public symlink" do
    rad[:environment]
    rad.config.environment.should == 'development'
    File.should exist("#{spec_dir}/app/runtime/public/plugin_b")
  end
  
  it "http call" do    
    workspace = nil
    Rad::HTTPAdapter.call Rad::HTTPAdapter.mock_environment do |c|
      c.call
      workspace = rad[:workspace]
    end
    # .should == [200, {"Content-Type" => "text/html"}, ""]      
    
    workspace.delete(:env).should be_a(Hash)
    expected_result = {path: "/", response: [200, {"Content-Type" => "text/html"}, ""], params: {format: 'html'}}
    workspace.to_h.subset(expected_result.keys).should == expected_result      
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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