Sha256: 9582ead3b84e967cf360532e3ab770b6f18e128808ed4799000ae0124bb0183a
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
#!/usr/bin/env ruby require 'specserv/rspec_gateway' require 'specserv/custom_exceptions' require 'sinatra' # possibly overkill, maybe just use thin or something? set :run, true # not sure about this, apparently Sinatra needs it to automatically launch a server before do @tester = Specserv::RSpecGateway.new def set_spec_path (spec_path) @spec_path = "#{spec_path}.rb" end def spec_file_exists? File.exists?(@spec_path) end def run_tests @results = @tester.run @spec_path end def malformed_results? @results.nil? || @results.strip == "" end def respond_with_results @results end def respond_with_404 status 404 "Could not find a spec file called #{@spec_path} in #{Dir.pwd}" end def respond_with_500 status 500 "There was an error generating results for #{@spec_path}" end end ## Index Page ## get '/' do 'SpecServ Test Result Server' end ## Result Pages ## get "/:spec_path" do set_spec_path( params[:spec_path] ) begin raise Specserv::NoSpecFileError unless spec_file_exists? run_tests raise Specserv::MalformedResultsError if malformed_results? respond_with_results rescue Specserv::NoSpecFileError respond_with_404 rescue Specserv::MalformedResultsError respond_with_500 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
specserv-0.0.4 | bin/specserv |