felixclack-cijoe 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ class CIJoe
2
+ Version = VERSION = "0.9.1"
3
+ end
@@ -0,0 +1,8 @@
1
+ { "jobs": [
2
+ <% if joe.last_build %>
3
+ {"name":"<%= joe.project %>",
4
+ "url":"<%= joe.url %>",
5
+ "color":"<%= joe.last_build.status.to_s == "failed" ? 'red' : 'blue' %>"
6
+ }
7
+ <% end %>
8
+ ]}
@@ -0,0 +1,43 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <link href="<%= cijoe_root %>/screen.css" media="screen" rel="stylesheet" type="text/css" />
5
+ <title><%= h(joe.project) %>: CI Joe</title>
6
+ </head>
7
+ <body>
8
+ <div class="site">
9
+ <div id="home">
10
+ <ul class="posts">
11
+ <% if joe.current_build %>
12
+ <li>
13
+ <span class="date"><%= pretty_time(joe.current_build.started_at) if joe.current_build %></span> &raquo;
14
+ <% if joe.current_build.sha %>
15
+ Building <%= joe.current_build.branch %> at <a href="<%= joe.current_build.commit.url %>"><%= joe.current_build.short_sha %></a> <small>(pid: <%= joe.pid %>)</small>
16
+ <% else %>
17
+ Build starting...
18
+ <% end %>
19
+ </li>
20
+ <% else %>
21
+ <li><form method="POST"><input type="submit" value="Build"/></form></li>
22
+ <% end %>
23
+
24
+ <% if joe.last_build %>
25
+ <li>
26
+ <span class="date"><%= pretty_time(joe.last_build.finished_at) %></span> &raquo;
27
+ <% if joe.last_build.sha %>
28
+ Built <%= joe.last_build.branch %> at <a href="<%= joe.last_build.commit.url %>"><%= joe.last_build.short_sha %></a>
29
+ <% end %>
30
+ <span class="<%= joe.last_build.status %>">(<%= joe.last_build.status %>)</span>
31
+ <% if joe.last_build.duration %>
32
+ in <span class="duration"><%= joe.last_build.duration %></span> seconds.
33
+ <% end %>
34
+ </li>
35
+ <% if joe.last_build.failed? %>
36
+ <li><pre class="terminal"><code><%=ansi_color_codes h(joe.last_build.output) %></code></pre></li>
37
+ <% end %>
38
+ <% end %>
39
+ </ul>
40
+ </div>
41
+ </div>
42
+ </body>
43
+ </html>
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ ENV['RACK_ENV'] = 'test'
5
+
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
+ require 'cijoe'
9
+
10
+ CIJoe::Server.set :project_path, "."
11
+ CIJoe::Server.set :environment, "test"
12
+
13
+ class Test::Unit::TestCase
14
+ end
@@ -0,0 +1,17 @@
1
+ require 'helper'
2
+
3
+ class TestCIJoe < Test::Unit::TestCase
4
+ def test_raise_error_on_invalid_command
5
+ assert_raise RuntimeError, LoadError do
6
+ CIJoe::Config.new('--invalid').to_s
7
+ end
8
+ end
9
+
10
+ def test_return_value_of_config
11
+ assert_equal `git config blame`.chomp, CIJoe::Config.new('blame').to_s
12
+ end
13
+
14
+ def test_return_empty_string_when_config_does_not_exist
15
+ assert_equal '', CIJoe::Config.new('invalid').to_s
16
+ end
17
+ end
@@ -0,0 +1,93 @@
1
+ require "helper"
2
+ require "rack/test"
3
+ require "cijoe/server"
4
+
5
+ class TestCIJoeServer < Test::Unit::TestCase
6
+ include Rack::Test::Methods
7
+
8
+ class ::CIJoe
9
+ attr_writer :current_build, :last_build
10
+ end
11
+
12
+ attr_accessor :app
13
+
14
+ def setup
15
+ @app = CIJoe::Server.new
16
+ # make Build#restore a no-op so we don't overwrite our current/last
17
+ # build attributes set from tests.
18
+ joe = @app.joe
19
+ def joe.restore
20
+ end
21
+ end
22
+
23
+ def test_ping
24
+ app.joe.last_build = build :worked
25
+ assert !app.joe.building?, "have a last build, but not a current"
26
+
27
+ get "/ping"
28
+ assert_equal 200, last_response.status
29
+ assert_equal app.joe.last_build.sha, last_response.body
30
+ end
31
+
32
+ def test_ping_building
33
+ app.joe.current_build = build :building
34
+ assert app.joe.building?, "buildin' a awsum project"
35
+
36
+ get "/ping"
37
+ assert_equal 412, last_response.status
38
+ assert_equal "building", last_response.body
39
+ end
40
+
41
+ def test_ping_building_with_a_previous_build
42
+ app.joe.last_build = build :worked
43
+ app.joe.current_build = build :building
44
+ assert app.joe.building?, "buildin' a awsum project"
45
+
46
+ get "/ping"
47
+ assert_equal 412, last_response.status
48
+ assert_equal "building", last_response.body
49
+ end
50
+
51
+ def test_ping_failed
52
+ app.joe.last_build = build :failed
53
+
54
+ get "/ping"
55
+ assert_equal 412, last_response.status
56
+ assert_equal app.joe.last_build.sha, last_response.body
57
+ end
58
+
59
+ def test_ping_should_not_reset_current_build_in_tests
60
+ current_build = build :building
61
+ app.joe.current_build = current_build
62
+ assert app.joe.building?
63
+ get "/ping"
64
+ assert_equal current_build, app.joe.current_build
65
+ end
66
+
67
+ def test_jsonp_should_return_plain_json_without_param
68
+ app.joe.last_build = build :failed
69
+ get "/api/json"
70
+ assert_equal 200, last_response.status
71
+ assert_equal 'application/json', last_response.content_type
72
+ end
73
+
74
+ def test_jsonp_should_return_jsonp_with_param
75
+ app.joe.last_build = build :failed
76
+ get "/api/json?jsonp=fooberz"
77
+ puts last_response.inspect
78
+ assert_equal 200, last_response.status
79
+ assert_equal 'application/json', last_response.content_type
80
+ assert_match /^fooberz\(/, last_response.body
81
+
82
+ end
83
+
84
+ def test_should_not_barf_when_no_build
85
+ end
86
+
87
+ # Create a new, fake build. All we care about is status.
88
+
89
+ def build status
90
+ CIJoe::Build.new "path", "user", "project", Time.now, Time.now,
91
+ "deadbeef", status, "output", nil
92
+ end
93
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: felixclack-cijoe
3
+ version: !ruby/object:Gem::Version
4
+ hash: 57
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 9
9
+ - 1
10
+ version: 0.9.1
11
+ platform: ruby
12
+ authors:
13
+ - Chris Wanstrath
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-04-01 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: choice
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: sinatra
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: rack-test
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :development
62
+ version_requirements: *id003
63
+ description: " cijoe is a sinatra-based continuous integration server. It's like an\n old rusty pickup truck: it might be smelly and gross, but it gets the\n job done.\n"
64
+ email: chris@ozmm.org
65
+ executables:
66
+ - cijoe
67
+ extensions: []
68
+
69
+ extra_rdoc_files: []
70
+
71
+ files:
72
+ - README.md
73
+ - Rakefile
74
+ - LICENSE
75
+ - lib/cijoe/build.rb
76
+ - lib/cijoe/campfire.rb
77
+ - lib/cijoe/commit.rb
78
+ - lib/cijoe/config.rb
79
+ - lib/cijoe/public/favicon.ico
80
+ - lib/cijoe/public/octocat.png
81
+ - lib/cijoe/public/screen.css
82
+ - lib/cijoe/server.rb
83
+ - lib/cijoe/version.rb
84
+ - lib/cijoe/views/json.erb
85
+ - lib/cijoe/views/template.erb
86
+ - lib/cijoe.rb
87
+ - bin/cijoe
88
+ - test/helper.rb
89
+ - test/test_cijoe.rb
90
+ - test/test_cijoe_server.rb
91
+ has_rdoc: false
92
+ homepage: http://github.com/felixclack/cijoe
93
+ licenses: []
94
+
95
+ post_install_message:
96
+ rdoc_options: []
97
+
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ hash: 3
115
+ segments:
116
+ - 0
117
+ version: "0"
118
+ requirements: []
119
+
120
+ rubyforge_project:
121
+ rubygems_version: 1.3.7
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: cijoe builds your builds.
125
+ test_files: []
126
+