bait 0.4.1 → 0.5.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.
@@ -0,0 +1,17 @@
1
+ require 'bait/pubsub'
2
+
3
+ describe Bait do
4
+ describe ".broadcast" do
5
+ let (:stream) { double(:stream) }
6
+ let (:format) { "data: [\"foo\",\"bar\",\"baz\"]\n\n" }
7
+ context 'one subscriber' do
8
+ before { Bait.add_subscriber stream }
9
+ it "broadcasts data to the subscriber" do
10
+ stream.should_receive(:<<).with(format)
11
+ Bait.broadcast :foo, :bar, :baz
12
+ end
13
+ after { Bait.remove_subscriber stream }
14
+ end
15
+ end
16
+ end
17
+
@@ -3,91 +3,58 @@ require 'bait/tester'
3
3
 
4
4
  describe Bait::Tester do
5
5
  let(:build) { Bait::Build.create(name: "bait", clone_url:repo_path) }
6
- let(:tester) { build.tester }
6
+ let(:tester) { Bait::Tester.new }
7
7
 
8
- describe "#sandbox_directory" do
9
- it "creates a directory on disk" do
10
- Dir.exists?(tester.sandbox_directory).should be_true
11
- end
12
-
13
- it "is beneath Bait storage directory" do
14
- tester.sandbox_directory.should match Bait.storage_dir
15
- end
16
- end
17
-
18
- describe "#cloned?" do
19
- specify { tester.should_not be_cloned }
20
- end
21
-
22
- describe "#clone!" do
23
- context 'valid clone url' do
24
- before { tester.clone! }
25
- specify { build.output.should_not match /Failed to clone/ }
26
- specify { tester.should be_cloned }
27
- end
28
- context "invalid clone url" do
29
- let(:build) { Bait::Build.create(name: "bait", clone_url:'invalid') }
30
- before { tester.clone! }
31
- specify { build.output.should match /Failed to clone/ }
32
- specify { tester.should_not be_cloned }
33
- end
34
- end
35
-
36
- describe "#test!" do
8
+ describe "#perform" do
37
9
  shared_examples_for "a test run" do
38
10
  it "saves output into the build" do
39
- build.output.should match "this is a test script"
40
- end
41
- it "is marked as tested" do
42
- build.should be_tested
11
+ build.reload.output.should match "this is a test script"
43
12
  end
44
13
  end
45
14
 
46
- before do
47
- tester.clone!
48
- end
49
-
50
15
  subject { build.reload }
16
+ before { build.clone! }
51
17
 
52
- context "does not have a test script" do
18
+ describe "real-time events" do
53
19
  before do
54
- FileUtils.rm tester.script
55
- tester.test!
20
+ write_script_with_status build.script, 0
21
+ end
22
+ it "push updates directly to the browser" do
23
+ Bait.should_receive(:broadcast).with(:build, :status, build.id, 'testing')
24
+ Bait.should_receive(:broadcast).with(:build, :output, build.id, kind_of(String))
25
+ Bait.should_receive(:broadcast).with(:build, :status, build.id, 'passed')
26
+ tester.perform build.id
27
+ end
28
+ end
29
+
30
+ context "build repo did not have a test script" do
31
+ before do
32
+ FileUtils.rm build.script
33
+ tester.perform build.id
56
34
  end
57
- it { should_not be_tested }
58
35
  it "has errors in output" do
59
- subject.output.should match /script was expected but missing/
36
+ build.reload.output.should match /script was expected but missing/
37
+ end
38
+ it "has a useful status" do
39
+ build.reload.status.should eq "script missing"
60
40
  end
61
41
  end
62
42
 
63
43
  context "has a test script" do
44
+ before do
45
+ write_script_with_status build.script, status
46
+ tester.perform build.id
47
+ end
64
48
  context "successful" do
65
- before do
66
- write_script_with_status tester.script, 0
67
- tester.test!
68
- end
49
+ let(:status) { 0 }
69
50
  it { should be_passed }
70
51
  it_behaves_like "a test run"
71
52
  end
72
53
  context 'failure' do
73
- before do
74
- write_script_with_status tester.script, 1
75
- tester.test!
76
- end
54
+ let(:status) { 1 }
77
55
  it { should_not be_passed }
78
56
  it_behaves_like "a test run"
79
57
  end
80
58
  end
81
59
  end
82
-
83
- describe "cleanup!" do
84
- before do
85
- tester.clone!
86
- end
87
- it "removes the entire sandbox" do
88
- Dir.exists?(tester.sandbox_directory).should be_true
89
- tester.cleanup!
90
- Dir.exists?(tester.sandbox_directory).should be_false
91
- end
92
- end
93
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bait
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keyvan Fatehi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-02 00:00:00.000000000 Z
11
+ date: 2013-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,6 +122,34 @@ dependencies:
122
122
  - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: sinatra-contrib
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: sinatra-asset-snack
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
125
153
  - !ruby/object:Gem::Dependency
126
154
  name: moneta
127
155
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +220,20 @@ dependencies:
192
220
  - - '>='
193
221
  - !ruby/object:Gem::Version
194
222
  version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: sucker_punch
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - '>='
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - '>='
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
195
237
  description: Accepts github push event webhook to clone and execute .bait/test.sh
196
238
  email:
197
239
  - keyvan@digitalfilmtree.com
@@ -202,7 +244,6 @@ extra_rdoc_files: []
202
244
  files:
203
245
  - .bait/test.sh
204
246
  - .gitignore
205
- - .rspec
206
247
  - Gemfile
207
248
  - Gemfile.lock
208
249
  - Guardfile
@@ -210,6 +251,12 @@ files:
210
251
  - README.md
211
252
  - Rakefile
212
253
  - VERSION
254
+ - assets/js/bait.coffee
255
+ - assets/js/build.coffee
256
+ - assets/js/main.coffee
257
+ - assets/js/manual_clone.coffee
258
+ - assets/stylesheets/build.scss
259
+ - assets/stylesheets/main.scss
213
260
  - bait.gemspec
214
261
  - bin/bait
215
262
  - lib/bait.rb
@@ -217,11 +264,11 @@ files:
217
264
  - lib/bait/build.rb
218
265
  - lib/bait/cli.rb
219
266
  - lib/bait/object.rb
220
- - lib/bait/public/css/styles.css
221
267
  - lib/bait/public/fonts/ubuntu.woff
222
- - lib/bait/public/js/ansi2html.js
223
- - lib/bait/public/js/main.js
224
- - lib/bait/public/js/zepto.min.js
268
+ - lib/bait/public/javascript/ansi2html.js
269
+ - lib/bait/public/javascript/zepto.min.js
270
+ - lib/bait/public/stylesheets/reset.css
271
+ - lib/bait/pubsub.rb
225
272
  - lib/bait/simple_query.rb
226
273
  - lib/bait/tester.rb
227
274
  - lib/bait/version.rb
@@ -229,6 +276,7 @@ files:
229
276
  - lib/bait/views/layout.haml
230
277
  - spec/lib/bait/api_spec.rb
231
278
  - spec/lib/bait/build_spec.rb
279
+ - spec/lib/bait/pubsub_spec.rb
232
280
  - spec/lib/bait/tester_spec.rb
233
281
  - spec/lib/bait_spec.rb
234
282
  - spec/spec_helper.rb
@@ -253,13 +301,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
301
  version: '0'
254
302
  requirements: []
255
303
  rubyforge_project:
256
- rubygems_version: 2.0.3
304
+ rubygems_version: 2.0.5
257
305
  signing_key:
258
306
  specification_version: 4
259
307
  summary: build and integration test service
260
308
  test_files:
261
309
  - spec/lib/bait/api_spec.rb
262
310
  - spec/lib/bait/build_spec.rb
311
+ - spec/lib/bait/pubsub_spec.rb
263
312
  - spec/lib/bait/tester_spec.rb
264
313
  - spec/lib/bait_spec.rb
265
314
  - spec/spec_helper.rb
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --color --format documentation
@@ -1,77 +0,0 @@
1
- /*
2
- YUI 3.11.0 (build d549e5c)
3
- Copyright 2013 Yahoo! Inc. All rights reserved.
4
- Licensed under the BSD License.
5
- http://yuilibrary.com/license/
6
- */
7
-
8
- html{color:#000;background:#FFF}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0}table{border-collapse:collapse;border-spacing:0}fieldset,img{border:0}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal}ol,ul{list-style:none}caption,th{text-align:left}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal}q:before,q:after{content:''}abbr,acronym{border:0;font-variant:normal}sup{vertical-align:text-top}sub{vertical-align:text-bottom}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit}input,textarea,select{*font-size:100%}legend{color:#000}#yui3-css-stamp.cssreset{display:none}
9
-
10
- /* I like this color scheme:
11
- https://kuler.adobe.com/anggo-djago-color-theme-2691053/
12
- I like this too:
13
- https://kuler.adobe.com/Flat-User-Interface-5-color-theme-2678392/
14
- */
15
-
16
- @font-face {
17
- font-family: 'Ubuntu';
18
- font-style: normal;
19
- font-weight: 400;
20
- src: local('Ubuntu'), url(/fonts/ubuntu.woff) format('woff');
21
- }
22
-
23
- body {
24
- font-family: 'Ubuntu';
25
- background-color:RGB(255,254,254);
26
- }
27
-
28
- .build .header {
29
- border-top-left-radius: 10px;
30
- border-top-right-radius: 10px;
31
- padding: 5px;
32
- }
33
-
34
- .build .header.passed {
35
- background-color:RGB(71,213,86);
36
- }
37
-
38
- .build .header.failed {
39
- background-color: RGB(247,65,67);
40
- }
41
-
42
- .build .header .status_icon {
43
- float:right;
44
- padding:8px;
45
- }
46
-
47
- .build {
48
- border-radius:12px;
49
- border:2px solid RGB(201,49,20);
50
- margin:20px;
51
- }
52
-
53
- .actions {
54
- background-color:RGB(254,238,195);
55
- text-align:center;
56
- border-bottom-left-radius: 10px;
57
- border-bottom-right-radius: 10px;
58
- }
59
-
60
- .actions a {
61
- color: RGB(20,77,105);
62
- text-decoration:none;
63
- }
64
-
65
- .actions a:hover {
66
- color: RGB(201,49,20);
67
- }
68
-
69
- .build .output pre {
70
- cursor:pointer;
71
- color: white;
72
- background-color:black;
73
- max-height:100px;
74
- overflow-y:hidden;
75
- overflow-x:scroll;
76
- }
77
-
@@ -1,26 +0,0 @@
1
- function each_log(cb)
2
- {
3
- var logs = $('.build .output pre');
4
- $.each(logs, function(i,e) {cb(e)});
5
- }
6
-
7
- function expand_log_toggle(id)
8
- {
9
- $('#'+id).find('pre').css('max-height', '100%');
10
- }
11
-
12
- function L(og){console.log(og)}
13
- Zepto(function($){
14
- each_log(function(pre) {
15
- // Color them
16
- pre.innerHTML=ansi2html(pre.innerHTML);
17
- // Enable expansion toggle
18
- $(pre).on('click', function(e) {
19
- if ($(pre).css('max-height') === '100px')
20
- $(pre).css('max-height', '100%')
21
- else
22
- $(pre).css('max-height', '100px')
23
- });
24
- });
25
- })
26
-