Sha256: 911b553925b743f36abfce2c4af597e95bd8552bb46bba198af13c27548ed352

Contents?: true

Size: 1.01 KB

Versions: 23

Compression:

Stored size: 1.01 KB

Contents

namespace :h2spec do
	task :build do
		# Fetch the code:
		sh "go get github.com/spf13/cobra"
		sh "go get github.com/summerwind/h2spec"
		
		# This builds `h2spec` into the current directory
		sh "go build ~/go/src/github.com/summerwind/h2spec/cmd/h2spec/h2spec.go"
	end
	
	task :server do
		require 'async/reactor'
		require 'async/container'
		require 'async/http/server'
		require 'async/io/host_endpoint'
		
		endpoint = Async::IO::Endpoint.tcp('127.0.0.1', 7272)
		
		server = Async::HTTP::Server.for(endpoint, Async::HTTP::Protocol::HTTP2, "https") do |request|
			Protocol::HTTP::Response[200, {'content-type' => 'text/plain'}, ["Hello World"]]
		end
		
		@container = Async::Container.new
		
		Async.logger.info(self){"Starting server..."}
		@container.run(count: 1) do
			server.run
		end
	end
	
	task :test => :server do
		begin
			if test = ENV['TEST']
				sh("./h2spec", test, "-p", "7272")
			else
				sh("./h2spec", "-p", "7272")
			end
		ensure
			@container.stop(false)
		end
	end
	
	task :all => [:build, :test]
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
async-http-0.45.8 tasks/h2spec.rake
async-http-0.45.7 tasks/h2spec.rake
async-http-0.45.6 tasks/h2spec.rake