integrity 0.1.8 → 0.1.9

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 (249) hide show
  1. data/README.markdown +7 -0
  2. data/Rakefile +59 -132
  3. data/VERSION.yml +1 -1
  4. data/config/config.ru +29 -0
  5. data/config/config.sample.ru +6 -16
  6. data/config/config.sample.yml +15 -12
  7. data/config/config.yml +34 -0
  8. data/lib/integrity.rb +13 -13
  9. data/lib/integrity/app.rb +138 -0
  10. data/lib/integrity/author.rb +39 -0
  11. data/lib/integrity/build.rb +54 -31
  12. data/lib/integrity/commit.rb +71 -0
  13. data/lib/integrity/helpers.rb +3 -3
  14. data/lib/integrity/helpers/authorization.rb +2 -2
  15. data/lib/integrity/helpers/forms.rb +3 -3
  16. data/lib/integrity/helpers/pretty_output.rb +1 -1
  17. data/lib/integrity/helpers/rendering.rb +6 -1
  18. data/lib/integrity/helpers/resources.rb +9 -3
  19. data/lib/integrity/helpers/urls.rb +15 -13
  20. data/lib/integrity/installer.rb +45 -56
  21. data/lib/integrity/migrations.rb +31 -48
  22. data/lib/integrity/notifier.rb +14 -16
  23. data/lib/integrity/notifier/base.rb +29 -19
  24. data/lib/integrity/notifier/test_helpers.rb +100 -0
  25. data/lib/integrity/project.rb +69 -33
  26. data/lib/integrity/project_builder.rb +23 -14
  27. data/lib/integrity/scm/git.rb +15 -14
  28. data/lib/integrity/scm/git/uri.rb +9 -9
  29. data/test/acceptance/api_test.rb +97 -0
  30. data/test/acceptance/browse_project_builds_test.rb +65 -0
  31. data/test/acceptance/browse_project_test.rb +95 -0
  32. data/test/acceptance/build_notifications_test.rb +42 -0
  33. data/test/acceptance/create_project_test.rb +97 -0
  34. data/test/acceptance/delete_project_test.rb +53 -0
  35. data/test/acceptance/edit_project_test.rb +117 -0
  36. data/test/acceptance/error_page_test.rb +18 -0
  37. data/test/acceptance/helpers.rb +2 -0
  38. data/test/acceptance/installer_test.rb +62 -0
  39. data/test/acceptance/manual_build_project_test.rb +82 -0
  40. data/test/acceptance/notifier_test.rb +109 -0
  41. data/test/acceptance/project_syndication_test.rb +30 -0
  42. data/test/acceptance/stylesheet_test.rb +18 -0
  43. data/test/helpers.rb +59 -26
  44. data/test/helpers/acceptance.rb +19 -65
  45. data/test/helpers/acceptance/email_notifier.rb +55 -0
  46. data/test/helpers/acceptance/git_helper.rb +15 -15
  47. data/test/helpers/acceptance/textfile_notifier.rb +3 -3
  48. data/test/helpers/expectations.rb +0 -1
  49. data/test/helpers/expectations/be_a.rb +4 -4
  50. data/test/helpers/expectations/change.rb +5 -5
  51. data/test/helpers/expectations/have.rb +4 -4
  52. data/test/helpers/expectations/predicates.rb +4 -4
  53. data/test/helpers/fixtures.rb +44 -18
  54. data/test/helpers/initial_migration_fixture.sql +44 -0
  55. data/test/unit/build_test.rb +51 -0
  56. data/test/unit/commit_test.rb +83 -0
  57. data/test/unit/helpers_test.rb +56 -0
  58. data/test/unit/integrity_test.rb +18 -0
  59. data/test/unit/migrations_test.rb +56 -0
  60. data/test/unit/notifier_test.rb +123 -0
  61. data/test/unit/project_builder_test.rb +108 -0
  62. data/test/unit/project_test.rb +282 -0
  63. data/test/unit/scm_test.rb +54 -0
  64. data/vendor/webrat/History.txt +306 -0
  65. data/vendor/webrat/MIT-LICENSE.txt +19 -0
  66. data/vendor/webrat/README.rdoc +85 -0
  67. data/vendor/webrat/Rakefile +151 -0
  68. data/vendor/webrat/install.rb +1 -0
  69. data/vendor/webrat/lib/webrat.rb +34 -0
  70. data/vendor/webrat/lib/webrat/core.rb +14 -0
  71. data/vendor/webrat/lib/webrat/core/configuration.rb +98 -0
  72. data/vendor/webrat/lib/webrat/core/elements/area.rb +31 -0
  73. data/vendor/webrat/lib/webrat/core/elements/element.rb +33 -0
  74. data/vendor/webrat/lib/webrat/core/elements/field.rb +403 -0
  75. data/vendor/webrat/lib/webrat/core/elements/form.rb +103 -0
  76. data/vendor/webrat/lib/webrat/core/elements/label.rb +31 -0
  77. data/vendor/webrat/lib/webrat/core/elements/link.rb +90 -0
  78. data/vendor/webrat/lib/webrat/core/elements/select_option.rb +35 -0
  79. data/vendor/webrat/lib/webrat/core/locators.rb +20 -0
  80. data/vendor/webrat/lib/webrat/core/locators/area_locator.rb +38 -0
  81. data/vendor/webrat/lib/webrat/core/locators/button_locator.rb +54 -0
  82. data/vendor/webrat/lib/webrat/core/locators/field_by_id_locator.rb +37 -0
  83. data/vendor/webrat/lib/webrat/core/locators/field_labeled_locator.rb +56 -0
  84. data/vendor/webrat/lib/webrat/core/locators/field_locator.rb +25 -0
  85. data/vendor/webrat/lib/webrat/core/locators/field_named_locator.rb +41 -0
  86. data/vendor/webrat/lib/webrat/core/locators/form_locator.rb +19 -0
  87. data/vendor/webrat/lib/webrat/core/locators/label_locator.rb +34 -0
  88. data/vendor/webrat/lib/webrat/core/locators/link_locator.rb +66 -0
  89. data/vendor/webrat/lib/webrat/core/locators/locator.rb +20 -0
  90. data/vendor/webrat/lib/webrat/core/locators/select_option_locator.rb +59 -0
  91. data/vendor/webrat/lib/webrat/core/logging.rb +21 -0
  92. data/vendor/webrat/lib/webrat/core/matchers.rb +4 -0
  93. data/vendor/webrat/lib/webrat/core/matchers/have_content.rb +73 -0
  94. data/vendor/webrat/lib/webrat/core/matchers/have_selector.rb +74 -0
  95. data/vendor/webrat/lib/webrat/core/matchers/have_tag.rb +21 -0
  96. data/vendor/webrat/lib/webrat/core/matchers/have_xpath.rb +147 -0
  97. data/vendor/webrat/lib/webrat/core/methods.rb +61 -0
  98. data/vendor/webrat/lib/webrat/core/mime.rb +29 -0
  99. data/vendor/webrat/lib/webrat/core/save_and_open_page.rb +50 -0
  100. data/vendor/webrat/lib/webrat/core/scope.rb +350 -0
  101. data/vendor/webrat/lib/webrat/core/session.rb +281 -0
  102. data/vendor/webrat/lib/webrat/core/xml.rb +115 -0
  103. data/vendor/webrat/lib/webrat/core/xml/hpricot.rb +19 -0
  104. data/vendor/webrat/lib/webrat/core/xml/nokogiri.rb +76 -0
  105. data/vendor/webrat/lib/webrat/core/xml/rexml.rb +24 -0
  106. data/vendor/webrat/lib/webrat/core_extensions/blank.rb +58 -0
  107. data/vendor/webrat/lib/webrat/core_extensions/deprecate.rb +8 -0
  108. data/vendor/webrat/lib/webrat/core_extensions/detect_mapped.rb +12 -0
  109. data/vendor/webrat/lib/webrat/core_extensions/meta_class.rb +6 -0
  110. data/vendor/webrat/lib/webrat/core_extensions/nil_to_param.rb +5 -0
  111. data/vendor/webrat/lib/webrat/mechanize.rb +74 -0
  112. data/vendor/webrat/lib/webrat/merb.rb +9 -0
  113. data/vendor/webrat/lib/webrat/merb_session.rb +65 -0
  114. data/vendor/webrat/lib/webrat/rack.rb +24 -0
  115. data/vendor/webrat/lib/webrat/rails.rb +105 -0
  116. data/vendor/webrat/lib/webrat/rspec-rails.rb +13 -0
  117. data/vendor/webrat/lib/webrat/selenium.rb +154 -0
  118. data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/button.js +12 -0
  119. data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/label.js +16 -0
  120. data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/webrat.js +5 -0
  121. data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/webratlink.js +9 -0
  122. data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/webratlinkwithin.js +15 -0
  123. data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/webratselectwithoption.js +5 -0
  124. data/vendor/webrat/lib/webrat/selenium/matchers.rb +4 -0
  125. data/vendor/webrat/lib/webrat/selenium/matchers/have_content.rb +66 -0
  126. data/vendor/webrat/lib/webrat/selenium/matchers/have_selector.rb +49 -0
  127. data/vendor/webrat/lib/webrat/selenium/matchers/have_tag.rb +72 -0
  128. data/vendor/webrat/lib/webrat/selenium/matchers/have_xpath.rb +45 -0
  129. data/vendor/webrat/lib/webrat/selenium/selenium_extensions.js +6 -0
  130. data/vendor/webrat/lib/webrat/selenium/selenium_session.rb +247 -0
  131. data/vendor/webrat/lib/webrat/sinatra.rb +44 -0
  132. data/vendor/webrat/spec/fakes/test_session.rb +34 -0
  133. data/vendor/webrat/spec/integration/merb/Rakefile +35 -0
  134. data/vendor/webrat/spec/integration/merb/app/controllers/application.rb +2 -0
  135. data/vendor/webrat/spec/integration/merb/app/controllers/exceptions.rb +13 -0
  136. data/vendor/webrat/spec/integration/merb/app/controllers/testing.rb +18 -0
  137. data/vendor/webrat/spec/integration/merb/app/views/exceptions/not_acceptable.html.erb +63 -0
  138. data/vendor/webrat/spec/integration/merb/app/views/exceptions/not_found.html.erb +47 -0
  139. data/vendor/webrat/spec/integration/merb/app/views/layout/application.html.erb +12 -0
  140. data/vendor/webrat/spec/integration/merb/app/views/testing/show_form.html.erb +27 -0
  141. data/vendor/webrat/spec/integration/merb/config/environments/development.rb +15 -0
  142. data/vendor/webrat/spec/integration/merb/config/environments/rake.rb +11 -0
  143. data/vendor/webrat/spec/integration/merb/config/environments/test.rb +14 -0
  144. data/vendor/webrat/spec/integration/merb/config/init.rb +25 -0
  145. data/vendor/webrat/spec/integration/merb/config/rack.rb +11 -0
  146. data/vendor/webrat/spec/integration/merb/config/router.rb +33 -0
  147. data/vendor/webrat/spec/integration/merb/spec/spec.opts +1 -0
  148. data/vendor/webrat/spec/integration/merb/spec/spec_helper.rb +24 -0
  149. data/vendor/webrat/spec/integration/merb/spec/webrat_spec.rb +32 -0
  150. data/vendor/webrat/spec/integration/merb/tasks/merb.thor/app_script.rb +31 -0
  151. data/vendor/webrat/spec/integration/merb/tasks/merb.thor/common.rb +64 -0
  152. data/vendor/webrat/spec/integration/merb/tasks/merb.thor/gem_ext.rb +124 -0
  153. data/vendor/webrat/spec/integration/merb/tasks/merb.thor/main.thor +150 -0
  154. data/vendor/webrat/spec/integration/merb/tasks/merb.thor/ops.rb +93 -0
  155. data/vendor/webrat/spec/integration/merb/tasks/merb.thor/utils.rb +40 -0
  156. data/vendor/webrat/spec/integration/rails/Rakefile +30 -0
  157. data/vendor/webrat/spec/integration/rails/app/controllers/application.rb +15 -0
  158. data/vendor/webrat/spec/integration/rails/app/controllers/webrat_controller.rb +39 -0
  159. data/vendor/webrat/spec/integration/rails/app/views/webrat/before_redirect_form.html.erb +4 -0
  160. data/vendor/webrat/spec/integration/rails/app/views/webrat/form.html.erb +28 -0
  161. data/vendor/webrat/spec/integration/rails/config/boot.rb +109 -0
  162. data/vendor/webrat/spec/integration/rails/config/environment.rb +12 -0
  163. data/vendor/webrat/spec/integration/rails/config/environments/development.rb +17 -0
  164. data/vendor/webrat/spec/integration/rails/config/environments/selenium.rb +22 -0
  165. data/vendor/webrat/spec/integration/rails/config/environments/test.rb +22 -0
  166. data/vendor/webrat/spec/integration/rails/config/initializers/inflections.rb +10 -0
  167. data/vendor/webrat/spec/integration/rails/config/initializers/mime_types.rb +5 -0
  168. data/vendor/webrat/spec/integration/rails/config/initializers/new_rails_defaults.rb +17 -0
  169. data/vendor/webrat/spec/integration/rails/config/locales/en.yml +5 -0
  170. data/vendor/webrat/spec/integration/rails/config/routes.rb +14 -0
  171. data/vendor/webrat/spec/integration/rails/public/404.html +30 -0
  172. data/vendor/webrat/spec/integration/rails/public/422.html +30 -0
  173. data/vendor/webrat/spec/integration/rails/public/500.html +33 -0
  174. data/vendor/webrat/spec/integration/rails/script/about +4 -0
  175. data/vendor/webrat/spec/integration/rails/script/console +3 -0
  176. data/vendor/webrat/spec/integration/rails/script/dbconsole +3 -0
  177. data/vendor/webrat/spec/integration/rails/script/destroy +3 -0
  178. data/vendor/webrat/spec/integration/rails/script/generate +3 -0
  179. data/vendor/webrat/spec/integration/rails/script/performance/benchmarker +3 -0
  180. data/vendor/webrat/spec/integration/rails/script/performance/profiler +3 -0
  181. data/vendor/webrat/spec/integration/rails/script/performance/request +3 -0
  182. data/vendor/webrat/spec/integration/rails/script/plugin +3 -0
  183. data/vendor/webrat/spec/integration/rails/script/process/inspector +3 -0
  184. data/vendor/webrat/spec/integration/rails/script/process/reaper +3 -0
  185. data/vendor/webrat/spec/integration/rails/script/process/spawner +3 -0
  186. data/vendor/webrat/spec/integration/rails/script/runner +3 -0
  187. data/vendor/webrat/spec/integration/rails/script/server +3 -0
  188. data/vendor/webrat/spec/integration/rails/test/integration/webrat_test.rb +80 -0
  189. data/vendor/webrat/spec/integration/rails/test/test_helper.rb +25 -0
  190. data/vendor/webrat/spec/integration/sinatra/Rakefile +5 -0
  191. data/vendor/webrat/spec/integration/sinatra/classic_app.rb +64 -0
  192. data/vendor/webrat/spec/integration/sinatra/modular_app.rb +16 -0
  193. data/vendor/webrat/spec/integration/sinatra/test/classic_app_test.rb +37 -0
  194. data/vendor/webrat/spec/integration/sinatra/test/modular_app_test.rb +18 -0
  195. data/vendor/webrat/spec/integration/sinatra/test/test_helper.rb +16 -0
  196. data/vendor/webrat/spec/private/core/configuration_spec.rb +104 -0
  197. data/vendor/webrat/spec/private/core/field_spec.rb +67 -0
  198. data/vendor/webrat/spec/private/core/link_spec.rb +24 -0
  199. data/vendor/webrat/spec/private/core/logging_spec.rb +10 -0
  200. data/vendor/webrat/spec/private/core/session_spec.rb +198 -0
  201. data/vendor/webrat/spec/private/mechanize/mechanize_session_spec.rb +81 -0
  202. data/vendor/webrat/spec/private/merb/merb_session_spec.rb +42 -0
  203. data/vendor/webrat/spec/private/nokogiri_spec.rb +77 -0
  204. data/vendor/webrat/spec/private/rails/attaches_file_spec.rb +81 -0
  205. data/vendor/webrat/spec/private/rails/rails_session_spec.rb +110 -0
  206. data/vendor/webrat/spec/private/selenium/selenium_session_spec.rb +44 -0
  207. data/vendor/webrat/spec/private/selenium/selenium_spec.rb +109 -0
  208. data/vendor/webrat/spec/public/basic_auth_spec.rb +24 -0
  209. data/vendor/webrat/spec/public/check_spec.rb +191 -0
  210. data/vendor/webrat/spec/public/choose_spec.rb +118 -0
  211. data/vendor/webrat/spec/public/click_area_spec.rb +106 -0
  212. data/vendor/webrat/spec/public/click_button_spec.rb +502 -0
  213. data/vendor/webrat/spec/public/click_link_spec.rb +469 -0
  214. data/vendor/webrat/spec/public/fill_in_spec.rb +209 -0
  215. data/vendor/webrat/spec/public/locators/field_by_xpath_spec.rb +19 -0
  216. data/vendor/webrat/spec/public/locators/field_labeled_spec.rb +157 -0
  217. data/vendor/webrat/spec/public/locators/field_with_id_spec.rb +16 -0
  218. data/vendor/webrat/spec/public/matchers/contain_spec.rb +114 -0
  219. data/vendor/webrat/spec/public/matchers/have_selector_spec.rb +135 -0
  220. data/vendor/webrat/spec/public/matchers/have_tag_spec.rb +39 -0
  221. data/vendor/webrat/spec/public/matchers/have_xpath_spec.rb +123 -0
  222. data/vendor/webrat/spec/public/reload_spec.rb +10 -0
  223. data/vendor/webrat/spec/public/save_and_open_spec.rb +51 -0
  224. data/vendor/webrat/spec/public/select_date_spec.rb +88 -0
  225. data/vendor/webrat/spec/public/select_datetime_spec.rb +106 -0
  226. data/vendor/webrat/spec/public/select_spec.rb +246 -0
  227. data/vendor/webrat/spec/public/select_time_spec.rb +79 -0
  228. data/vendor/webrat/spec/public/set_hidden_field_spec.rb +5 -0
  229. data/vendor/webrat/spec/public/submit_form_spec.rb +5 -0
  230. data/vendor/webrat/spec/public/visit_spec.rb +58 -0
  231. data/vendor/webrat/spec/public/within_spec.rb +177 -0
  232. data/vendor/webrat/spec/rcov.opts +1 -0
  233. data/vendor/webrat/spec/spec.opts +2 -0
  234. data/vendor/webrat/spec/spec_helper.rb +50 -0
  235. data/vendor/webrat/vendor/selenium-server.jar +0 -0
  236. data/views/_commit_info.haml +24 -0
  237. data/views/build.haml +2 -2
  238. data/views/error.haml +4 -3
  239. data/views/home.haml +3 -5
  240. data/views/integrity.sass +19 -6
  241. data/views/new.haml +6 -6
  242. data/views/project.builder +9 -9
  243. data/views/project.haml +14 -12
  244. metadata +319 -124
  245. data/app.rb +0 -138
  246. data/integrity.gemspec +0 -76
  247. data/lib/integrity/core_ext/string.rb +0 -5
  248. data/test/helpers/expectations/have_tag.rb +0 -128
  249. data/views/_build_info.haml +0 -18
@@ -0,0 +1,282 @@
1
+ require File.dirname(__FILE__) + "/../helpers"
2
+
3
+ class ProjectTest < Test::Unit::TestCase
4
+ before(:each) do
5
+ RR.reset
6
+ ignore_logs!
7
+ end
8
+
9
+ specify "default fixture is valid and can be saved" do
10
+ lambda do
11
+ Project.generate.tap do |project|
12
+ project.should be_valid
13
+ project.save
14
+ end
15
+ end.should change(Project, :count).by(1)
16
+ end
17
+
18
+ specify "integrity fixture is valid and can be saved" do
19
+ lambda do
20
+ Project.generate(:integrity).tap do |project|
21
+ project.should be_valid
22
+ project.save
23
+ end
24
+ end.should change(Project, :count).by(1)
25
+ end
26
+
27
+ describe "Properties" do
28
+ before(:each) do
29
+ @project = Project.generate(:integrity)
30
+ end
31
+
32
+ it "has a name" do
33
+ @project.name.should == "Integrity"
34
+ end
35
+
36
+ it "has a permalink" do
37
+ @project.permalink.should == "integrity"
38
+
39
+ @project.tap do |project|
40
+ project.name = "foo's bar/baz and BACON?!"
41
+ project.save
42
+ end.permalink.should == "foos-bar-baz-and-bacon"
43
+ end
44
+
45
+ it "has an URI" do
46
+ @project.uri.should == Addressable::URI.parse("git://github.com/foca/integrity.git")
47
+ end
48
+
49
+ it "has a branch" do
50
+ @project.branch.should == "master"
51
+ end
52
+
53
+ specify "branch defaults to master" do
54
+ Project.new.branch.should == "master"
55
+ end
56
+
57
+ it "has a command" do
58
+ # TODO: rename to build_command
59
+ @project.command.should == "rake"
60
+ end
61
+
62
+ specify "command defaults to 'rake'" do
63
+ Project.new.command.should == "rake"
64
+ end
65
+
66
+ it "has a building flag" do
67
+ @project.should_not be_building
68
+ end
69
+
70
+ specify "building flag default to false" do
71
+ Project.new.should_not be_building
72
+ end
73
+
74
+ it "knows it's visibility" do
75
+ # TODO: rename Project#public property to visibility
76
+ # TODO: and have utility method to query its state instead
77
+
78
+ Project.new.should be_public
79
+
80
+ @project.should be_public
81
+ @project.tap { |p| p.public = "1" }.should be_public
82
+ @project.tap { |p| p.public = "0" }.should_not be_public
83
+
84
+ Project.gen(:public => "false").should be_public
85
+ Project.gen(:public => "true").should be_public
86
+ Project.gen(:public => false).should_not be_public
87
+ Project.gen(:public => nil).should_not be_public
88
+ end
89
+
90
+ it "has a created_at" do
91
+ @project.created_at.should be_a(DateTime)
92
+ end
93
+
94
+ it "has an updated_at" do
95
+ @project.updated_at.should be_a(DateTime)
96
+ end
97
+
98
+ it "knows it's status" do
99
+ Project.gen(:commits => 1.of{ Commit.gen(:successful) }).status.should == :success
100
+ Project.gen(:commits => 2.of{ Commit.gen(:successful) }).status.should == :success
101
+ Project.gen(:commits => 2.of{ Commit.gen(:failed) }).status.should == :failed
102
+ Project.gen(:commits => 1.of{ Commit.gen(:pending) }).status.should == :pending
103
+ Project.gen(:commits => []).status.should be_nil
104
+ end
105
+
106
+ it "knows it's last build" do
107
+ Project.gen(:commits => []).last_commit.should be_nil
108
+
109
+ commits = 5.of { Commit.gen(:successful) }
110
+ project = Project.gen(:commits => commits)
111
+ project.last_commit.should == commits.sort_by {|c| c.committed_at }.last
112
+ end
113
+ end
114
+
115
+ describe "Validation" do
116
+ it "requires a name" do
117
+ lambda do
118
+ Project.gen(:name => nil).should_not be_valid
119
+ end.should_not change(Project, :count)
120
+ end
121
+
122
+ it "requires an URI" do
123
+ lambda do
124
+ Project.gen(:uri => nil).should_not be_valid
125
+ end.should_not change(Project, :count)
126
+ end
127
+
128
+ it "requires a branch" do
129
+ lambda do
130
+ Project.gen(:branch => nil).should_not be_valid
131
+ end.should_not change(Project, :count)
132
+ end
133
+
134
+ it "requires a command" do
135
+ lambda do
136
+ Project.gen(:command => nil).should_not be_valid
137
+ end.should_not change(Project, :count)
138
+ end
139
+
140
+ it "ensures its name is unique" do
141
+ Project.gen(:name => "Integrity")
142
+ lambda do
143
+ Project.gen(:name => "Integrity").should_not be_valid
144
+ end.should_not change(Project, :count)
145
+ end
146
+ end
147
+
148
+ describe "Finding public or private projects" do
149
+ before(:each) do
150
+ @public_project = Project.gen(:public => true)
151
+ @private_project = Project.gen(:public => false)
152
+ end
153
+
154
+ it "finds only public projects if the condition passed is false" do
155
+ projects = Project.only_public_unless(false)
156
+ projects.should_not include(@private_project)
157
+ projects.should include(@public_project)
158
+ end
159
+
160
+ it "finds both private and public projects if the condition passed is true" do
161
+ projects = Project.only_public_unless(true)
162
+ projects.should include(@private_project)
163
+ projects.should include(@public_project)
164
+ end
165
+ end
166
+
167
+ describe "When finding its previous builds" do
168
+ before(:each) do
169
+ @project = Project.generate(:commits => 5.of { Commit.gen })
170
+ @commits = @project.commits.sort_by {|c| c.committed_at }.reverse
171
+ end
172
+
173
+ it "has 4 previous builds" do
174
+ @project.should have(4).previous_commits
175
+ end
176
+
177
+ it "returns the builds ordered chronogicaly (desc) by creation date" do
178
+ @project.previous_commits.should == @commits[1..-1]
179
+ end
180
+
181
+ it "excludes the last build" do
182
+ @project.previous_commits.should_not include(@project.last_commit)
183
+ end
184
+
185
+ it "returns an empty array if it has only one build" do
186
+ project = Project.gen(:commits => 1.of { Integrity::Commit.gen })
187
+ project.should have(:no).previous_commits
188
+ end
189
+
190
+ it "returns an empty array if there are no builds" do
191
+ project = Project.gen(:commits => [])
192
+ project.should have(:no).previous_commits
193
+ end
194
+ end
195
+
196
+ describe "When getting destroyed" do
197
+ before(:each) do
198
+ @commits = 7.of { Commit.gen }
199
+ @project = Project.generate(:commits => @commits)
200
+ end
201
+
202
+ it "destroys itself and tell ProjectBuilder to delete the code from disk" do
203
+ lambda do
204
+ stub.instance_of(ProjectBuilder).delete_code
205
+ @project.destroy
206
+ end.should change(Project, :count).by(-1)
207
+ end
208
+
209
+ it "destroys its builds" do
210
+ lambda do
211
+ @project.destroy
212
+ end.should change(Commit, :count).by(-7)
213
+ end
214
+ end
215
+
216
+ describe "When retrieving state about its notifier" do
217
+ before(:each) do
218
+ @project = Project.generate
219
+ @irc = Notifier.generate(:irc)
220
+ end
221
+
222
+ specify "#config_for returns given notifier's configuration" do
223
+ @project.update_attributes(:notifiers => [@irc])
224
+ @project.config_for("IRC").should == {:uri => "irc://irc.freenode.net/integrity"}
225
+ end
226
+
227
+ specify "#config_for returns an empty hash if no such notifier" do
228
+ @project.config_for("IRC").should == {}
229
+ end
230
+
231
+ specify "#notifies? is true if it uses the given notifier" do
232
+ @project.update_attributes(:notifiers => [@irc])
233
+ @project.notifies?("IRC").should == true
234
+ end
235
+
236
+ specify "#notifies? is false if it doesnt use the given notifier" do
237
+ @project.update_attributes(:notifiers => [])
238
+
239
+ @project.notifies?("IRC").should == false
240
+ @project.notifies?("UndefinedNotifier").should == false
241
+ end
242
+ end
243
+
244
+ describe "When building a commit" do
245
+ before(:each) do
246
+ @commits = 2.of { Commit.gen }
247
+ @project = Project.gen(:integrity, :commits => @commits)
248
+ stub.instance_of(ProjectBuilder).build { nil }
249
+ end
250
+
251
+ it "gets the specified commit and creates a pending build for it" do
252
+ commit = @commits.last
253
+
254
+ lambda {
255
+ @project.build(commit.identifier)
256
+ }.should change(Build, :count).by(1)
257
+
258
+ build = Build.all.last
259
+ build.commit.should be(commit)
260
+ build.should be_pending
261
+
262
+ commit.should be_pending
263
+ end
264
+
265
+ it "creates an empty commit with the head of the project if passed 'HEAD' (the default)" do
266
+ mock(@project).head_of_remote_repo { "FOOBAR" }
267
+
268
+ lambda {
269
+ @project.build("HEAD")
270
+ }.should change(Commit, :count).by(1)
271
+
272
+ build = Build.all.last
273
+ build.commit.should be(@project.last_commit)
274
+
275
+ @project.last_commit.should be_pending
276
+ @project.last_commit.identifier.should be("FOOBAR")
277
+
278
+ @project.last_commit.author.name.should == "<Commit author not loaded>"
279
+ @project.last_commit.message.should == "<Commit message not loaded>"
280
+ end
281
+ end
282
+ end
@@ -0,0 +1,54 @@
1
+ require File.dirname(__FILE__) + "/../helpers"
2
+
3
+ class SCMTest < Test::Unit::TestCase
4
+ def scm(uri)
5
+ SCM.new(Addressable::URI.parse(uri), "master", "foo")
6
+ end
7
+
8
+ it "recognizes git URIs" do
9
+ scm("git://example.org/repo").should be_an(SCM::Git)
10
+ scm("git@example.org/repo.git").should be_an(SCM::Git)
11
+ scm("git://example.org/repo.git").should be_an(SCM::Git)
12
+ end
13
+
14
+ it "raises SCMUnknownError if it can't figure the SCM from the URI" do
15
+ lambda { scm("scm://example.org") }.should raise_error(SCM::SCMUnknownError)
16
+ end
17
+
18
+ it "doesn't need the working tree path for all operations, so it's not required on the constructor" do
19
+ lambda {
20
+ SCM.new(Addressable::URI.parse("git://github.com/foca/integrity.git"), "master")
21
+ }.should_not raise_error
22
+ end
23
+
24
+ describe "SCM::Git::URI" do
25
+ uris = [
26
+ "rsync://host.xz/path/to/repo.git/",
27
+ "rsync://host.xz/path/to/repo.git",
28
+ "rsync://host.xz/path/to/repo.gi",
29
+ "http://host.xz/path/to/repo.git/",
30
+ "https://host.xz/path/to/repo.git/",
31
+ "git://host.xz/path/to/repo.git/",
32
+ "git://host.xz/~user/path/to/repo.git/",
33
+ "ssh://[user@]host.xz[:port]/path/to/repo.git/",
34
+ "ssh://[user@]host.xz/path/to/repo.git/",
35
+ "ssh://[user@]host.xz/~user/path/to/repo.git/",
36
+ "ssh://[user@]host.xz/~/path/to/repo.git",
37
+ "host.xz:/path/to/repo.git/",
38
+ "host.xz:~user/path/to/repo.git/",
39
+ "host.xz:path/to/repo.git",
40
+ "user@host.xz:/path/to/repo.git/",
41
+ "user@host.xz:~user/path/to/repo.git/",
42
+ "user@host.xz:path/to/repo.git",
43
+ "user@host.xz:path/to/repo",
44
+ "user@host.xz:path/to/repo.a_git"
45
+ ]
46
+
47
+ uris.each do |uri|
48
+ it "parses the uri #{uri}" do
49
+ git_url = SCM::Git::URI.new(uri)
50
+ git_url.working_tree_path.should == "path-to-repo"
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,306 @@
1
+ == Git (Unreleased)
2
+
3
+ * Minor enhancements
4
+
5
+ * Support for "modular" Sinatra app style (Simon Rozet)
6
+ * When faced with a label with no for attribute, that contains a hidden field
7
+ and another field, as can be the case in Rails 2.3's checkbox view,
8
+ webrat now locates the non-hidden field. (Luke Melia)
9
+ * When using Rails 2.3, use Rack::Utils to parse params (Matthew Ford)
10
+ * Initial Merb and Sinatra compatibility for Selenium mode (Corey Donohoe)
11
+ * Add application_framework config for Selenium mode to determine how to
12
+ start and stop the app server (Corey Donohoe)
13
+
14
+ * Bug fixes
15
+
16
+ * Fix following of absolute redirect URL in Sinatra (Simon Rozet)
17
+
18
+ == 0.4.2 / 2009-02-24
19
+
20
+ * Major enhancements
21
+
22
+ * Significant improvements to have_selector. It now supports specifying
23
+ attributes in a hash and :count and :content options. See
24
+ have_selector_spec.rb for more.
25
+ * Add the same functionality mentioned above to have_xpath
26
+
27
+ * Minor enhancements
28
+
29
+ * Squeeze extra whitespace out of failures messages from contain
30
+ matcher
31
+ * Detect infinite redirects and raise a Webrat::InfiniteRedirectError
32
+ (Daniel Lucraft)
33
+
34
+ * Bug fixes
35
+
36
+ * Properly quote single and double quotes strings in XPath
37
+ * Fix warning caused by Nokogiri deprecating CSS::Parser.parse
38
+ (Aaron Patterson)
39
+ * Accept do/end blocks in matchers. [#157] (Peter Jaros)
40
+ * Quote --chdir option to mongrel_rails to support RAILS_ROOTs with spaces
41
+ (T.J. VanSlyke)
42
+
43
+ == 0.4.1 / 2009-01-31
44
+
45
+ * Minor enhancements
46
+
47
+ * Support Sinatra 0.9 (Harry Vangberg)
48
+ * Update query param parsing to work with latest Edge Rails
49
+ * Added #redirected_to method to easily check where an external redirect was
50
+ redirected to (Adam Greene)
51
+ * Recognize input tags with type button (Lena Herrmann)
52
+ * Add uncheck method to Selenium mode (Lee Bankewitz)
53
+
54
+ * Bug fixes
55
+
56
+ * Make requests to a Rails app using a full URL instead of a relative path. This change
57
+ is helpful for Rails apps that use subdomains. (John Hwang and Zach Dennis)
58
+ * Follow redirects that are on the same domain but a different subdomain
59
+ (Adam Greene)
60
+ * rescue from Webrat::TimeoutError in selenium matchers which allows NegativeMatchers
61
+ to behave correctly (Noah Davis)
62
+ * Switch to using selenium.click instead of .check when checking a checkbox
63
+ (Noah Davis)
64
+ * Create tmp/pids directory if directory does not exist. (Amos King and Mike Gaffney)
65
+ * Setup deprecated writers for the selenium_environment= and selenium_port= config
66
+ * Ensure the previous pages params aren't passed through redirect (Daniel Lucraft and
67
+ Bryan Helmkamp)
68
+ * Labels should only search for fields within the current scope (Kyle Hargraves)
69
+
70
+ == 0.4.0 / 2009-01-18
71
+
72
+ * _IMPORTANT_ Breaking change:
73
+
74
+ * Removed init.rb auto-require of webrat/rails
75
+ * Removed auto-require of webrat/rails when requiring webrat when RAILS_ENV is
76
+ defined
77
+
78
+ In your env.rb or test_helper.rb file, ensure you have something like:
79
+
80
+ require "webrat"
81
+
82
+ Webrat.configure do |config|
83
+ config.mode = :rails
84
+ end
85
+
86
+ * Major enhancements
87
+
88
+ * Major improvements to Webrat::Selenium (Many contributors listed here)
89
+ * Add assert_* methods for using Webrat's matchers w/o RSpec (Mike Gaffney, Amos King)
90
+ * Added Webrat.configure method for Webrat configuration [#33] (Mike Gaffney)
91
+ * Added select_time, select_date, and select_datetime to API. [#36] (Ben Mabey)
92
+ * Use Hpricot and REXML when not parsing with Nokogiri (on JRuby, for example)
93
+
94
+ * Minor enhancements
95
+
96
+ * Added Selenium grid configuration and support. (Amos King && Cornel Borcean)
97
+ * Support passing an ActiveRecord model to #within when in Rails mode [#68] (Luke Melia)
98
+ * Make assert_* matchers in rails mode increment the assertions count [#123] (Amos King)
99
+ * Added assert_* matchers to selenium matchers [#110] (Amos King)
100
+ * Added assert_contain, assert_not_contain [#86] (Mike Gaffney, Amos King)
101
+ * Add configuration options for the Selenium environment and port (Kieran Pilkington)
102
+ * Maximize the browser window after initializing Selenium (Luke Melia)
103
+ * Better inspect output for Webrat elements
104
+ * Sets the Webrat mode with Configuration#mode= in the config block [#85] (Mike Gaffney)
105
+ * Detect if the document is XML or HTML using the Content-Type when in Rails mode
106
+ * Expose #selenium method for direct access to Selenium client
107
+ * Check nokogiri gem version before requiring nokogiri
108
+ * Include the Selenium server jar file in the gem (Bryan Helmkamp, Ben Schwarz)
109
+ * Added key_down, key_up and fire_event to Selenium session (Fernando Garcia)
110
+ * Fix outputing README during Rails plugin install (Fernando Garcia)
111
+ * Strip newlines when matching label text (Miha Filej)
112
+ * Add simple support for accessing Webrat's matchers from RSpec by requiring
113
+ "webrat/rspec-rails" (David Chelimsky)
114
+ * Support save_and_open_page in Windows and Cygwin (Mike Gaffney)
115
+ * Added RadioField#checked? to indicated whether or not a radio button is checked
116
+ (Luke Melia)
117
+ * Add spec:jruby rake task for running Webrat's spec suite with JRuby
118
+ * Added field_by_xpath to locate a Webrat::Field using arbitrary XPath expressions
119
+ * Helpful error message for missing option values [#40] (Ben Mabey)
120
+ * Add set_hidden_field method (Noah Davis, Bryan Helmkamp)
121
+ * Add submit_form method for submitting a form by ID (Noah Davis, Bryan Helmkamp)
122
+ * Switch to using Nokogiri.parse for simple XML/XHTML autodetection [#66]
123
+ * Removed Webrat.root method, which seemed to be unused
124
+ * Added automatic starting and stopping of the Selenium server and a Mongrel Rails
125
+ app server when using webrat/selenium
126
+ * Switch to using selenium-client gem and vendor selenium-server.jar (Luke Melia)
127
+ * Added gemspec so the gem builds on GitHub now
128
+ * Deprecate old style methods (fills_in is deprecated in favor of fill_in, etc.)
129
+ * Improvements to the README and RDoc (Bryan Helmkamp, Mike Gaffney)
130
+ * Allow clicking links by id and id regexp (Mike Gaffney)
131
+ * Raise Webrat::DisabledFieldError when attempting to manipulate a disabled field
132
+ * Raise Webrat::NotFoundErrors when an element is not found
133
+ * Raise Webrat::PageLoadError when a failure occurs so that application exceptions
134
+ can be more accurately tested (Ryan Briones)
135
+ * Helpful error message for missing option in select box. [#40] (Ben Mabey)
136
+ * Extracted save_and_open page to make it usable in Selenium mode (Luke Melia)
137
+ * Added save_and_open_screengrab for Selenium mode (Luke Melia)
138
+
139
+ * Bug fixes
140
+
141
+ * field_labeled should disregard labels without matching fields (Kyle Hargraves)
142
+ * Fixed bug where Scope was creating a new DOM rather than re-using the existing DOM.
143
+ [#105] (Zach Dennis)
144
+ * Support Rails > v2.2 by using ActionController::RequestParser for param parsing [#107]
145
+ (Marcello Nuccio)
146
+ * Raise a Webrat::NotFoundError if the scope passed to #within doesn't exist [#90]
147
+ * Match against link _text_ which decodes character references.
148
+ Useful for multibyte languages like Japanese (moronatural@gmail.com)
149
+ * Fix params hash generation for Mechanize when Merb is not defined [#62]
150
+ * Expose some Webrat methods that were missing from the Webrat::Methods module
151
+ (Low Chin Chau)
152
+ * Allow mechanize session to pass through basic auth (Ryan Briones)
153
+ * Improvements to the Mechanize support (Jeremy Burks)
154
+ * Fix following fully qualified local links (Lawrence Pit)
155
+ * Fixed bug where Webrat would lose complex parameters (like foo[bar[baz]][])
156
+ in Merb due to not correctly merging Mashes. (Drew Colthorp)
157
+ * Extend Rails' ActionController::IntegrationTest instead of
158
+ ActionController::Integration::Session (Fixes using Webrat's #select method and
159
+ avoids usage of method_missing)
160
+ * Ensure that Webrat::MechanizeSession.request_page always uses an absolute
161
+ URL. (Graham Ashton)
162
+ * Strip anchor tags from URIs before passing to Rails integration session
163
+ (Noah Davis)
164
+ * Treat text and regexp when matching Selenium buttons (Ross Kaffenberger)
165
+ * Allow SeleniumSession's click_button to be called without an argument without
166
+ blowing up (Luke Melia)
167
+
168
+ == 0.3.4 / 2008-12-29
169
+
170
+ * 1 Minor enhancement
171
+
172
+ * Fix compatibility with Nokogiri 1.1.0 on JRuby
173
+
174
+ * 1 Bug fix
175
+
176
+ * Correct version for Nokogiri dependency in gem
177
+
178
+ == 0.3.3 / 2008-12-28
179
+
180
+ * 1 Minor enhancement
181
+
182
+ * Fix compatibility with Nokogiri 1.1.0 on MRI
183
+
184
+ == 0.3.2 / 2008-11-08
185
+
186
+ * 1 Minor enhancement
187
+
188
+ * Fixes behavior or have_tag when a block is passed. It passes the matched node(s)
189
+ to the block for further specs again. (Carl Lerche)
190
+
191
+ == 0.3.1 / 2008-11-07
192
+
193
+ * 1 Minor enhancement
194
+
195
+ * Use @_webrat_session instance variable instead of @session for Merb integration
196
+ to avoid collisions
197
+
198
+ == 0.3.0 / 2008-11-07
199
+
200
+ * 4 Major enhancements
201
+
202
+ * Added Merb support (Gwyn Morfey, Jeremy Burks, Rob Kaufman, Yehuda Katz)
203
+ * Added experimental Selenium support (Luke Melia)
204
+ * Add have_selector, have_xpath, have_tag and contain matchers from Merb
205
+ * Switch from Hpricot to Nokogiri for XML parsing (thanks, Aaron Patterson)
206
+
207
+ * 37 Minor enhancements
208
+
209
+ * Added #within for manipulating the current page within a selector scope
210
+ * Add support for file fields via #attaches_file method (Rails only at the moment)
211
+ (Kyle Hargraves)
212
+ * Add support for simulating SSL requests (Luke Melia)
213
+ * Added #basic_auth(user, pass) to support HTTP Basic Auth (Aslak Hellesøy)
214
+ * Added support for Sinatra and Rack (Aslak Hellesøy)
215
+ * Rename visits to visit, fills_in to fill_in, etc.
216
+ * Add #field_labeled for looking up form fields by label (David Chelimsky)
217
+ * Add #field_named and #field_with_id locators
218
+ * Don't depend on hoe anymore
219
+ * Return responses after sending requests
220
+ * Allow clicking links and buttons by a regular expression in Selenium (Luke Melia)
221
+ * Allow clicking links by a regular expression
222
+ * Add #http_accept for including MIME type HTTP "Accept" headers (Ryan Briones)
223
+ * Add #header to support inclusion of custom HTTP headers (Ryan Briones)
224
+ * Consider response codes 200-499 as successful enough to not raise a Webrat error
225
+ (David Leal)
226
+ * Add support for clicking areas of an image map (Alex Lang)
227
+ * Support relative links, including href="?foo=bar" (Kyle Hargraves)
228
+ * Separated Rails-specific code from the Webrat core to make it easier to use
229
+ Webrat with other environments
230
+ * Alias visits as visit, clicks_link as click_link, etc. for better readability
231
+ * Raise error when trying to interact with a disabled form element (Luke Melia)
232
+ * Don't send disabled form elements to the server (Nicholas A. Evans)
233
+ * Display response body when the page load is not successful (David Leal)
234
+ * CGI escape form field values (Miha Filej)
235
+ * Add support for redirect_to :back by sending HTTP_REFERER headers
236
+ (Hendrik Volkmer)
237
+ * Expose current DOM (as an Hpricot object) as #current_dom
238
+ * Add support for disabling JavaScript when clicking a link to enable testing of
239
+ both JS and non-JS implementations (Luke Melia and Bryan Helmkamp)
240
+ * Support &nbsp's as spaces in matching link text (Luke Melia)
241
+ * Support button elements (Nick Sieger)
242
+ * Support matching select options by regexp (Kyle Hargraves)
243
+ * save_and_open_page rewrites css and image references to provide a friendlier
244
+ debugging experience (Luke Melia)
245
+ * Added support for matching alt attributes in fields (primarly for clicks_button)
246
+ (Aaron Quint)
247
+ * Support '&amp;' in submitted values (Kyle Hargraves)
248
+ * Support clicking links by title (Dan Barry)
249
+ * Added missing spec for clicking image buttons (Tim Harper)
250
+ * Switched tests to specs, and from Mocha to RSpec's mocking library
251
+ * Add support to click_button for IDs (Gwyn Morfey)
252
+ * Miscellaneous core refactorings (Jan Suchal)
253
+
254
+ * 8 Bug fixes
255
+
256
+ * Fix initialization of WWW::Mechanize (Derek Kastner)
257
+ * Don't open blank pages in the browser (Kyle Hargraves)
258
+ * Support radio buttons with multiple labels (Dan Barry)
259
+ * Fix load order bug on some platforms (Ismael Celis)
260
+ * Fix bug with empty select list option (Kyle Hargraves)
261
+ * Fix regression of not sending default values in password fields
262
+ * Don't explode if encountering inputs with no type attribute (assume text)
263
+ * Fix bug where choosing a radio button in a series with a default submitted the
264
+ incorrect field value (Luke Melia)
265
+
266
+ == 0.2.0 / 2008-04-04
267
+
268
+ * 4 Major enhancements
269
+
270
+ * Add save_and_open_page to aid in debugging
271
+ * Add radio button support via #chooses method
272
+ * Add basic support for Rails-generated JavaScript link tags
273
+ * Add support for checkboxes (Patches from Kyle Hargraves and Jarkko Laine)
274
+ * Add support for textarea fields (Sacha Schlegel)
275
+
276
+ * 8 Minor enhancements
277
+
278
+ * Added reloads method to reload the page (Kamal Fariz Mahyuddi)
279
+ * Prevent making a request if clicking on local anchor link (Kamal Fariz Mahyuddi)
280
+ * Added clicks_link_within(selector, link_text), allowing restricting link search
281
+ to within a given css selector (Luke Melia)
282
+ * Allow specifying the input name/label when doing a select (David Chelimsky)
283
+ * Raise a specific exception if the developer tries to manipulate form elements
284
+ before loading a page (James Deville)
285
+ * Add support for alternate POST, PUT and DELETE link clicking (Kyle Hargraves)
286
+ * Change clicks_link to find the shortest matching link (Luke Melia)
287
+ * Improve matching for labels in potentially ambiguous cases
288
+
289
+ * 7 Bug fixes
290
+
291
+ * Fix incorrect serializing of collection inputs, i.e. name contains []
292
+ (Kamal Fariz Mahyuddi)
293
+ * Serialize empty text field values just like browsers (Kamal Fariz Mahyuddi)
294
+ * Quick fix to avoid @dom not initialized warnings (Kamal Fariz Mahyuddi)
295
+ * Docfix: bad reference to #select method in README (Luke Melia)
296
+ * Ensure Rails-style checkboxes work properly (checkboxes followed by a hidden
297
+ input with the same name)
298
+ * Fix Edge Rails (a.k.a. 2.0 RC) compatibility (David Chelimsky)
299
+ * Support param hashes nested more than one level (David Chelimsky)
300
+
301
+ == 0.1.0 / 2007-11-28
302
+
303
+ * 1 major enhancement
304
+
305
+ * Birthday!
306
+