specserv 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/specserv.rb +73 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f0bbe4326eda1211045d8cb739abab5c8e59543b
4
+ data.tar.gz: d5f2aae278824cb632e02de02484b2c97feb6ca3
5
+ SHA512:
6
+ metadata.gz: 75d071902b16197e60533ef510e88a113337d867c0fd3c635985dfa887f43c0cc689cd9178a1b26769bcce6a820e7667996592b068ffb9330b1f59747ca746a5
7
+ data.tar.gz: 184abd595f2bbad998502aef3eb3eda99a4d11126bad88ce37bf824da5d689d6e2ad4a96b321d2cd42fc180ba12ffc23a8a97f77a256fe79c0edad3ab8d30f9e
data/lib/specserv.rb ADDED
@@ -0,0 +1,73 @@
1
+ require 'sinatra'
2
+
3
+ class NoSpecFileError < StandardError; end
4
+
5
+ class MalformedResultsError < StandardError; end
6
+
7
+ class RSpecGateway
8
+ def run( source_path )
9
+ `rspec --format html #{source_path}` # TODO run RSpec through RSpec::Core::Runner rather than through executable
10
+ end
11
+ end
12
+
13
+ before do
14
+ @tester = RSpecGateway.new
15
+
16
+ def set_spec_path (spec_path)
17
+ @spec_path = "#{spec_path}.rb"
18
+ end
19
+
20
+ def spec_file_exists?
21
+ File.exists?(@spec_path)
22
+ end
23
+
24
+ def run_tests
25
+ @results = @tester.run @spec_path
26
+ end
27
+
28
+ def malformed_results?
29
+ @results.nil? || @results.strip == ""
30
+ end
31
+
32
+ def respond_with_results
33
+ @results
34
+ end
35
+
36
+ def respond_with_404
37
+ status 404
38
+ "Could not find a spec file called #{@spec_path}!"
39
+ end
40
+
41
+ def respond_with_500
42
+ status 500
43
+ "There was an error generating results for #{@spec_path}!"
44
+ end
45
+ end
46
+
47
+
48
+ ## Index Page ##
49
+
50
+ get '/' do
51
+ 'SpecServ Test Result Server'
52
+ end
53
+
54
+
55
+ ## Result Pages ##
56
+
57
+ get "/:spec_path" do
58
+
59
+ set_spec_path( params[:spec_path] )
60
+
61
+ begin
62
+ raise NoSpecFileError unless spec_file_exists?
63
+ run_tests
64
+ raise MalformedResultsError if malformed_results?
65
+ respond_with_results
66
+
67
+ rescue NoSpecFileError
68
+ respond_with_404
69
+
70
+ rescue MalformedResultsError
71
+ respond_with_500
72
+ end
73
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: specserv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Andy Brice
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Dynamically serves test results via HTTP from any directory.
14
+ email:
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/specserv.rb
20
+ homepage: https://github.com/andybrice/specserv
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.2.2
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Test result server
44
+ test_files: []