foca-integrity 0.1.4 → 0.1.6

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 (53) hide show
  1. data/README.markdown +19 -106
  2. data/Rakefile +53 -25
  3. data/VERSION.yml +1 -1
  4. data/app.rb +24 -153
  5. data/bin/integrity +2 -80
  6. data/config/config.sample.ru +2 -1
  7. data/config/config.sample.yml +4 -0
  8. data/integrity.gemspec +16 -11
  9. data/lib/integrity/build.rb +10 -5
  10. data/lib/integrity/helpers/authorization.rb +33 -0
  11. data/lib/integrity/helpers/breadcrumbs.rb +20 -0
  12. data/lib/integrity/helpers/forms.rb +28 -0
  13. data/lib/integrity/helpers/pretty_output.rb +45 -0
  14. data/lib/integrity/helpers/rendering.rb +14 -0
  15. data/lib/integrity/helpers/resources.rb +13 -0
  16. data/lib/integrity/helpers/urls.rb +47 -0
  17. data/lib/integrity/helpers.rb +16 -0
  18. data/lib/integrity/installer.rb +133 -0
  19. data/lib/integrity/migrations.rb +50 -0
  20. data/lib/integrity/notifier/base.rb +1 -1
  21. data/lib/integrity/notifier.rb +2 -2
  22. data/lib/integrity/project.rb +40 -13
  23. data/lib/integrity/{builder.rb → project_builder.rb} +1 -3
  24. data/lib/integrity/scm/git.rb +4 -4
  25. data/lib/integrity/scm.rb +5 -8
  26. data/lib/integrity.rb +37 -26
  27. data/test/helpers/acceptance/git_helper.rb +99 -0
  28. data/test/helpers/acceptance/textfile_notifier.rb +26 -0
  29. data/test/helpers/acceptance.rb +126 -0
  30. data/test/helpers/expectations/be_a.rb +23 -0
  31. data/test/helpers/expectations/change.rb +90 -0
  32. data/test/helpers/expectations/have.rb +105 -0
  33. data/test/helpers/expectations/have_tag.rb +128 -0
  34. data/test/helpers/expectations/predicates.rb +37 -0
  35. data/test/helpers/expectations.rb +5 -0
  36. data/test/helpers/fixtures.rb +83 -0
  37. data/test/helpers.rb +48 -0
  38. data/views/_build_info.haml +18 -0
  39. data/views/build.haml +1 -1
  40. data/views/error.haml +10 -3
  41. data/views/home.haml +3 -2
  42. data/views/integrity.sass +1 -1
  43. data/views/layout.haml +3 -0
  44. data/views/new.haml +10 -13
  45. data/views/notifier.haml +1 -1
  46. data/views/project.builder +21 -0
  47. data/views/project.haml +9 -13
  48. metadata +38 -11
  49. data/lib/integrity/core_ext/time.rb +0 -13
  50. data/spec/form_field_matchers.rb +0 -91
  51. data/spec/spec_helper.rb +0 -135
  52. data/vendor/sinatra-hacks/lib/hacks.rb +0 -49
  53. data/views/build_info.haml +0 -22
@@ -1,91 +0,0 @@
1
- module FormFieldHpricotMatchers
2
- # TODO: Add support for selects
3
- class HaveField
4
- include RspecHpricotMatchers
5
-
6
- def initialize(id, type, tagname)
7
- @tagname = tagname
8
- @type = type
9
- @id = id
10
- @tag_matcher = have_tag("#{@tagname}##{@id}", @tagname == "textarea" ? @value : nil)
11
- @label_set = true # always check for a label, unless explicitly told not to
12
- end
13
-
14
- def named(name)
15
- @name_set = true
16
- @name = name
17
- self
18
- end
19
-
20
- def with_label(label)
21
- @label = label
22
- self
23
- end
24
-
25
- def without_label
26
- @label_set = false
27
- self
28
- end
29
-
30
- def with_value(value)
31
- @value_set = true
32
- @value = value
33
- self
34
- end
35
-
36
- def checked
37
- @checked = "checked"
38
- self
39
- end
40
-
41
- def unchecked
42
- @checked = ""
43
- self
44
- end
45
-
46
- def matches?(actual)
47
- (@label_set ? have_tag("label[@for=#{@id}]", @label).matches?(actual) : true) &&
48
- @tag_matcher.matches?(actual) do |field|
49
- field["type"].should == @type if @type
50
- field["name"].should == @name if @name_set
51
- field["value"].should == @value if @value_set && @tagname == "input"
52
- field["checked"].should == @checked if @checked
53
- end
54
- end
55
-
56
- def failure_message
57
- attrs = [
58
- "id ##{@id}",
59
- @name && "name '#{@name}'",
60
- @type && "type '#{@type}'",
61
- @label && "labelled '#{@label}'",
62
- @value && "value '#{@value}'"
63
- ].compact.join(", ")
64
- "You expected a #{@tagname}#{@type ? " (#{@type})" : ""} with #{attrs} but found none.\n\n#{@tag_matcher.failure_message}"
65
- end
66
- end
67
-
68
- def have_field(id, type="text", tagname="input")
69
- HaveField.new(id, type, tagname)
70
- end
71
-
72
- def have_textfield(id)
73
- have_field(id)
74
- end
75
-
76
- def have_password(id)
77
- have_field(id, "password")
78
- end
79
-
80
- def have_checkbox(id)
81
- have_field(id, "checkbox")
82
- end
83
-
84
- def have_radio(id)
85
- have_field(id, "radio")
86
- end
87
-
88
- def have_textarea(id)
89
- have_field(id, nil, "textarea")
90
- end
91
- end
data/spec/spec_helper.rb DELETED
@@ -1,135 +0,0 @@
1
- require File.dirname(__FILE__) + '/../lib/integrity'
2
- require 'spec'
3
-
4
- module LoggingSpecHelper
5
- def self.included(mod)
6
- mod.before(:each) { Integrity.stub!(:log) }
7
- end
8
- end
9
-
10
- module NotifierSpecHelper
11
- def self.included(mod)
12
- mod.before(:each) { Integrity.stub!(:config).and_return(:base_uri => "http://localhost:4567") }
13
- end
14
-
15
- class Integrity::Notifier::Stub < Integrity::Notifier::Base
16
- def self.to_haml
17
- ""
18
- end
19
-
20
- def deliver!
21
- nil
22
- end
23
- end
24
-
25
- def mock_build(messages={})
26
- messages = {
27
- :project => stub("project", :name => "Integrity", :permalink => "integrity"),
28
- :commit_identifier => "e7e02bc669d07064cdbc7e7508a21a41e040e70d",
29
- :short_commit_identifier => "e7e02b",
30
- :status => :success,
31
- :successful? => true,
32
- :commit_message => "the commit message",
33
- :commit_author => stub("author", :name => "Nicolás Sanguinetti"),
34
- :commited_at => Time.mktime(2008, 07, 25, 18, 44),
35
- :output => "the output \e[31mwith color coding\e[0m"
36
- }.merge(messages)
37
- @build ||= stub("build", messages)
38
- end
39
-
40
- def notifier_config(overrides={})
41
- @config ||= overrides
42
- end
43
-
44
- def notifier
45
- @notifier ||= stub("notifier", :method_missing => nil)
46
- end
47
-
48
- def the_form(locals = {})
49
- locals = { :config => {} }.merge(locals)
50
- require 'haml'
51
- @form ||= Haml::Engine.new(klass.to_haml).render(self, locals)
52
- end
53
- end
54
-
55
- describe "A notifier", :shared => true do
56
- it "should have a `notify_of_build' class method" do
57
- klass.should respond_to(:notify_of_build)
58
- end
59
-
60
- it "should have a `to_haml' class method" do
61
- klass.should respond_to(:to_haml)
62
- end
63
- end
64
-
65
- module DatabaseSpecHelper
66
- def self.included(mod)
67
- mod.before(:each) { setup_database! }
68
- end
69
-
70
- def setup_database!
71
- DataMapper.setup(:default, 'sqlite3::memory:')
72
- DataMapper.auto_migrate!
73
- end
74
- end
75
-
76
- module AppSpecHelper
77
- def self.included(mod)
78
- require 'rspec_hpricot_matchers'
79
- require Integrity.root / 'spec/form_field_matchers'
80
-
81
- mod.send(:include, DatabaseSpecHelper)
82
- mod.send(:include, RspecHpricotMatchers)
83
- mod.send(:include, FormFieldHpricotMatchers)
84
- end
85
-
86
- def mock_project(messages={})
87
- messages = {
88
- :name => "Integrity",
89
- :permalink => "integrity",
90
- :new_record? => false,
91
- :uri => "git://github.com/foca/integrity.git",
92
- :branch => "master",
93
- :command => "rake",
94
- :public? => true,
95
- :builds => [],
96
- :config_for => {},
97
- :build => nil,
98
- :update_attributes => true,
99
- :save => true,
100
- :destroy => nil,
101
- :errors => stub("errors", :on => nil),
102
- :notifies? => false,
103
- :enable_notifiers => nil
104
- }.merge(messages)
105
-
106
- @project ||= stub("project", messages)
107
- end
108
-
109
- def mock_build(messages={})
110
- messages = {
111
- :status => :success,
112
- :successful? => true,
113
- :output => 'output',
114
- :project => @project,
115
- :commit_identifier => '9f6302002d2259c05a64767e0dedb15d280a4848',
116
- :commit_author => mock("author",
117
- :name => 'Nicolás Sanguinetti',
118
- :email => 'contacto@nicolassanguinetti.info',
119
- :full =>'Nicolás Sanguinetti <contacto@nicolassanguinetti.info>'
120
- ),
121
- :commited_at => Time.mktime(2008, 7, 24, 17, 15),
122
- :commit_message => "Add Object#tap for versions of ruby that don't have it"
123
- }.merge(messages)
124
- messages[:short_commit_identifier] = messages[:commit_identifier][0..5]
125
- mock('build', messages)
126
- end
127
-
128
- def disable_basic_auth!
129
- Integrity.stub!(:config).and_return(:use_basic_auth => false)
130
- end
131
-
132
- def enable_basic_auth!
133
- Integrity.stub!(:config).and_return(:use_basic_auth => true, :admin_username => 'user', :admin_password => 'pass')
134
- end
135
- end
@@ -1,49 +0,0 @@
1
- module Sinatra
2
- class EventContext
3
- def params
4
- @params ||= ParamsParser.new(@route_params.merge(@request.params)).to_hash
5
- end
6
-
7
- private
8
-
9
- class ParamsParser
10
- attr_reader :hash
11
-
12
- def initialize(hash)
13
- @hash = nested(hash)
14
- end
15
-
16
- alias :to_hash :hash
17
-
18
- protected
19
-
20
- def nested(hash)
21
- hash.inject(indifferent_hash) do |par, (key,val)|
22
- if key =~ /([^\[]+)\[([^\]]+)\](.*)/ # a[b] || a[b][c] ($1 == a, $2 == b, $3 == [c])
23
- par[$1] ||= indifferent_hash
24
- par[$1].merge_recursive nested("#{$2}#{$3}" => val)
25
- else
26
- par[key] = val
27
- end
28
- par
29
- end
30
- end
31
-
32
- def indifferent_hash
33
- Hash.new {|h,k| h[k.to_s] if Symbol === k}
34
- end
35
- end
36
- end
37
- end
38
-
39
- class Hash
40
- def merge_recursive(other)
41
- update(other) do |key, old_value, new_value|
42
- if Hash === old_value && Hash === new_value
43
- old_value.merge_recursive(new_value)
44
- else
45
- new_value
46
- end
47
- end
48
- end
49
- end
@@ -1,22 +0,0 @@
1
- %h1
2
- Built
3
- &= @build.short_commit_identifier
4
- = @build.successful? ? "successfully" : "and failed"
5
- %blockquote
6
- %p&= @build.commit_message
7
- %p.meta<
8
- %span.who<
9
- by:
10
- &= @build.commit_author.name
11
- |
12
- %span.when{ :title => @build.commited_at.iso8601 }<
13
- &= pretty_date @build.commited_at
14
- |
15
- %span.what<
16
- commit:
17
- &= @build.commit_identifier
18
-
19
- %h2 Build Output:
20
- %pre.output
21
- :preserve
22
- #{bash_color_codes h(@build.output)}