jfrench-integritray 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  coverage
4
4
  rdoc
5
5
  pkg
6
+ *.log
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -0,0 +1,46 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{integritray}
5
+ s.version = "0.1.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Josh French"]
9
+ s.date = %q{2009-07-08}
10
+ s.email = %q{josh@digitalpulp.com}
11
+ s.extra_rdoc_files = [
12
+ "LICENSE",
13
+ "README.rdoc"
14
+ ]
15
+ s.files = [
16
+ ".document",
17
+ ".gitignore",
18
+ "LICENSE",
19
+ "README.rdoc",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "integritray.gemspec",
23
+ "lib/integrity/integritray.rb",
24
+ "test/acceptance/acceptance_helper.rb",
25
+ "test/acceptance/integritray_test.rb"
26
+ ]
27
+ s.homepage = %q{http://github.com/jfrench/integritray}
28
+ s.rdoc_options = ["--charset=UTF-8"]
29
+ s.require_paths = ["lib"]
30
+ s.rubygems_version = %q{1.3.4}
31
+ s.summary = %q{CCMenu support for Integrity}
32
+ s.test_files = [
33
+ "test/acceptance/acceptance_helper.rb",
34
+ "test/acceptance/integritray_test.rb"
35
+ ]
36
+
37
+ if s.respond_to? :specification_version then
38
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
39
+ s.specification_version = 3
40
+
41
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
42
+ else
43
+ end
44
+ else
45
+ end
46
+ end
@@ -21,13 +21,29 @@ class Integrity::App < Sinatra::Default
21
21
  opts = {}
22
22
  opts['name'] = project.name
23
23
  opts['category'] = project.branch
24
- opts['activity'] = project.building? ? 'Building' : 'Sleeping'
24
+ opts['activity'] = activity(project.last_commit.status)
25
25
  opts['webUrl'] = project_url(project)
26
26
  if project.last_commit
27
- opts['lastBuildStatus'] = project.last_commit.status.to_s.capitalize
27
+ opts['lastBuildStatus'] = build_status(project.last_commit.status)
28
28
  opts['lastBuildLabel'] = project.last_commit.short_identifier
29
29
  opts['lastBuildTime'] = project.last_commit.build.completed_at if project.last_commit.build
30
30
  end
31
31
  opts
32
32
  end
33
+
34
+ def activity(status)
35
+ case status
36
+ when :success, :failed then 'Sleeping'
37
+ when :pending then 'Building'
38
+ else 'Sleeping'
39
+ end
40
+ end
41
+
42
+ def build_status(status)
43
+ case status
44
+ when :success, :pending then 'Success'
45
+ when :failed then 'Failure'
46
+ else 'Unknown'
47
+ end
48
+ end
33
49
  end
@@ -0,0 +1,150 @@
1
+ $:.unshift File.dirname(__FILE__) + "/../lib", File.dirname(__FILE__)
2
+
3
+ require "rubygems"
4
+
5
+ require "test/unit"
6
+ require "rr"
7
+ require "mocha"
8
+ require "dm-sweatshop"
9
+ require "webrat/sinatra"
10
+
11
+ gem "jeremymcanally-context"
12
+ gem "jeremymcanally-matchy"
13
+ gem "jeremymcanally-pending"
14
+ require "context"
15
+ require "matchy"
16
+ require "pending"
17
+
18
+ require "integrity"
19
+ require "integrity/notifier/test/fixtures"
20
+
21
+ begin
22
+ require "ruby-debug"
23
+ require "redgreen"
24
+ rescue LoadError
25
+ end
26
+
27
+ module TestHelper
28
+ def ignore_logs!
29
+ Integrity.config[:log] = "/tmp/integrity.test.log"
30
+ end
31
+
32
+ def capture_stdout
33
+ output = StringIO.new
34
+ $stdout = output
35
+ yield
36
+ $stdout = STDOUT
37
+ output
38
+ end
39
+
40
+ def silence_warnings
41
+ $VERBOSE, v = nil, $VERBOSE
42
+ yield
43
+ ensure
44
+ $VERBOSE = v
45
+ end
46
+ end
47
+
48
+ class Test::Unit::TestCase
49
+ class << self
50
+ alias_method :specify, :test
51
+ end
52
+
53
+ include RR::Adapters::TestUnit
54
+ include Integrity
55
+ include TestHelper
56
+
57
+ before(:all) do
58
+ DataMapper.setup(:default, "sqlite3::memory:")
59
+
60
+ require "integrity/migrations"
61
+ end
62
+
63
+ before(:each) do
64
+ [Project, Build, Commit, Notifier].each{ |i| i.auto_migrate_down! }
65
+ capture_stdout { Integrity.migrate_db }
66
+ Notifier.available.clear
67
+ Integrity.instance_variable_set(:@config, nil)
68
+ end
69
+
70
+ after(:each) do
71
+ capture_stdout { Integrity::Migrations.migrate_down! }
72
+ end
73
+ end
74
+
75
+ gem "foca-storyteller"
76
+ require "storyteller"
77
+
78
+ module AcceptanceHelper
79
+ include FileUtils
80
+
81
+ def export_directory
82
+ File.dirname(__FILE__) + "/../../exports"
83
+ end
84
+
85
+ def enable_auth!
86
+ Integrity.config[:use_basic_auth] = true
87
+ Integrity.config[:admin_username] = "admin"
88
+ Integrity.config[:admin_password] = "test"
89
+ Integrity.config[:hash_admin_password] = false
90
+ end
91
+
92
+ def login_as(user, password)
93
+ def AcceptanceHelper.logged_in; true; end
94
+ basic_auth user, password
95
+ visit "/login"
96
+ Integrity::App.before { login_required if AcceptanceHelper.logged_in }
97
+ end
98
+
99
+ def log_out
100
+ def AcceptanceHelper.logged_in; false; end
101
+ @_webrat_session = Webrat::SinatraSession.new(self)
102
+ end
103
+
104
+ def disable_auth!
105
+ Integrity.config[:use_basic_auth] = false
106
+ end
107
+
108
+ def set_and_create_export_directory!
109
+ FileUtils.rm_r(export_directory) if File.directory?(export_directory)
110
+ FileUtils.mkdir(export_directory)
111
+ Integrity.config[:export_directory] = export_directory
112
+ end
113
+
114
+ def setup_log!
115
+ log_file = Pathname(File.dirname(__FILE__) + "/../../integrity.log")
116
+ log_file.delete if log_file.exist?
117
+ Integrity.config[:log] = log_file
118
+ end
119
+ end
120
+
121
+ class Test::Unit::AcceptanceTestCase < Test::Unit::TestCase
122
+ include AcceptanceHelper
123
+ include Test::Storyteller
124
+ include Webrat::Methods
125
+ include Webrat::Matchers
126
+ include Webrat::HaveTagMatcher
127
+
128
+ Webrat::Methods.delegate_to_session :response_code
129
+
130
+ def app
131
+ Integrity::App
132
+ end
133
+
134
+ before(:all) do
135
+ app.set(:environment, :test)
136
+ end
137
+
138
+ before(:each) do
139
+ # ensure each scenario is run in a clean sandbox
140
+ Integrity.config[:base_uri] = "http://www.example.com"
141
+ enable_auth!
142
+ setup_log!
143
+ set_and_create_export_directory!
144
+ log_out
145
+ end
146
+
147
+ after(:each) do
148
+ rm_r export_directory if File.directory?(export_directory)
149
+ end
150
+ end
@@ -2,7 +2,7 @@
2
2
  # I've been copying this into an unpacked version of Integrity and running it
3
3
  # there.
4
4
 
5
- require File.dirname(__FILE__) + "/../helpers/acceptance"
5
+ require File.dirname(__FILE__) + "/acceptance_helper"
6
6
  require 'integrity/integritray'
7
7
 
8
8
  class IntegritrayTest < Test::Unit::AcceptanceTestCase
@@ -25,6 +25,34 @@ class IntegritrayTest < Test::Unit::AcceptanceTestCase
25
25
  assert_have_tag("projects/project[@weburl='#{project_url(project)}']")
26
26
  assert_have_tag("projects/project[@category='#{project.branch}']")
27
27
  assert_have_tag("projects/project[@activity='Sleeping']")
28
- assert_have_tag("projects/project[@lastbuildstatus='#{commit.status}']")
28
+ assert_have_tag("projects/project[@lastbuildstatus='Success']")
29
+ end
30
+
31
+ scenario "projects.xml has a tag representing my pending project" do
32
+ project = Project.gen(:integrity, :public => true, :commits => 2.of { Commit.gen(:pending)})
33
+ commit = project.last_commit
34
+ visit "/projects.xml"
35
+
36
+ assert_have_tag("projects")
37
+ assert_have_tag("projects/project[@name='Integrity']")
38
+ assert_have_tag("projects/project[@lastbuildlabel='#{commit.short_identifier}']")
39
+ assert_have_tag("projects/project[@weburl='#{project_url(project)}']")
40
+ assert_have_tag("projects/project[@category='#{project.branch}']")
41
+ assert_have_tag("projects/project[@activity='Building']")
42
+ assert_have_tag("projects/project[@lastbuildstatus='Success']")
43
+ end
44
+
45
+ scenario "projects.xml has a tag representing my failed project" do
46
+ project = Project.gen(:integrity, :public => true, :commits => 2.of { Commit.gen(:failed)})
47
+ commit = project.last_commit
48
+ visit "/projects.xml"
49
+
50
+ assert_have_tag("projects")
51
+ assert_have_tag("projects/project[@name='Integrity']")
52
+ assert_have_tag("projects/project[@lastbuildlabel='#{commit.short_identifier}']")
53
+ assert_have_tag("projects/project[@weburl='#{project_url(project)}']")
54
+ assert_have_tag("projects/project[@category='#{project.branch}']")
55
+ assert_have_tag("projects/project[@activity='Sleeping']")
56
+ assert_have_tag("projects/project[@lastbuildstatus='Failure']")
29
57
  end
30
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jfrench-integritray
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh French
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-29 00:00:00 -07:00
12
+ date: 2009-07-08 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -29,7 +29,9 @@ files:
29
29
  - README.rdoc
30
30
  - Rakefile
31
31
  - VERSION
32
+ - integritray.gemspec
32
33
  - lib/integrity/integritray.rb
34
+ - test/acceptance/acceptance_helper.rb
33
35
  - test/acceptance/integritray_test.rb
34
36
  has_rdoc: false
35
37
  homepage: http://github.com/jfrench/integritray
@@ -58,4 +60,5 @@ signing_key:
58
60
  specification_version: 3
59
61
  summary: CCMenu support for Integrity
60
62
  test_files:
63
+ - test/acceptance/acceptance_helper.rb
61
64
  - test/acceptance/integritray_test.rb