Sha256: 778d7ee9624bf220e6aa26aaea362f8973321a8537a8cae74ad7db834f201df0

Contents?: true

Size: 1.69 KB

Versions: 8

Compression:

Stored size: 1.69 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "Hayabusa" do
  it "should be able to start a sample-server" do
    require "rubygems"
    require "http2"
    require "json"
    
    Http2.new(:host => "localhost") do |http|
      res = http.post(:url => "hayabusa_cgi_test/vars_post_test.rhtml", :post => {
        "var" => {
          0 => 1,
          1 => 2,
          3 => {
            "kasper" => 5,
            "arr" => ["a", "b", "c"]
          }
        }
      })
      
      begin
        data = JSON.parse(res.body)
      rescue JSON::GeneratorError
        raise "Could not parse JSON from result: '#{res.body}'."
      end
      
      begin
        raise "Expected hash to be a certain way: '#{data}'." if data["var"]["0"] != "1" or data["var"]["1"] != "2" or data["var"]["3"]["kasper"] != "5" or data["var"]["3"]["arr"]["0"] != "a" or data["var"]["3"]["arr"]["1"] != "b"
      rescue => e
        raise "Error when parsing result: '#{data}'."
      end
      
      
      res = http.get("hayabusa_cgi_test/threadded_content_test.rhtml")
      raise "Expected body to be '123456' but it was: '#{res.body}'." if res.body != "123456"
      
      res = http.get("hayabusa_cgi_test/vars_get_test.rhtml?var[]=1&var[]=2&var[]=3&var[3][kasper]=5")
      data = JSON.parse(res.body)
      raise "Expected hash to be a certain way: '#{data}'." if data["var"]["0"] != "1" or data["var"]["1"] != "2" or data["var"]["3"]["kasper"] != "5"
      
      
      
      res = http.get("hayabusa_cgi_test/vars_header_test.rhtml")
      raise "Expected header 'testheader' to be 'TestValue' but it wasnt: '#{res.header("testheader")}'." if res.header("testheader") != "TestValue"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hayabusa-0.0.9 spec/cgi_spec.rb
hayabusa-0.0.8 spec/cgi_spec.rb
hayabusa-0.0.6 spec/cgi_spec.rb
hayabusa-0.0.5 spec/cgi_spec.rb
hayabusa-0.0.4 spec/cgi_spec.rb
hayabusa-0.0.3 spec/cgi_spec.rb
hayabusa-0.0.2 spec/cgi_spec.rb
hayabusa-0.0.1 spec/cgi_spec.rb