bait 0.5.2 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fe195857876671d375066afecae961fb185ccb1
4
- data.tar.gz: 53d06eac61cdd882820ae351d40dab48f81fa55e
3
+ metadata.gz: 58891295fc38209a37141334e62a3a03561bcffc
4
+ data.tar.gz: 0aefe33c5cd7c7f2cbb9a3231a8258e196352f53
5
5
  SHA512:
6
- metadata.gz: 29d4ae74154488fbb614dd99b00405bbf46cea6a0a526a31cadf581a54ee3a6093f7c3cece7c83652fe84282e5846a935a42c4dce9bb3ce360e4ca7dccfe06a2
7
- data.tar.gz: 534f2278236b01cd6230c42d6b8a175f38ddfd68c775d3256b85c9376c2ff8b5f21e5b938f3fbbd98da5e9a680d936fea866b57d1b1ef1c45751657832b301af
6
+ metadata.gz: 1127e37a377f460b70fcdccec3a8b6491b6636b5cddfa6479475ea622ecda0f77623679572f23fc167927a90ab0841f040864106f37eb9a9409e62d73d3ef9ad
7
+ data.tar.gz: 5b544f86eca0307b17b5fb6e9547eea4659c9fc5e57ec8f76e14867bbcf9f673dda983321bf6eb7bfad91b7aa8e9f0febe4d4ace33015132637a077d096ed764
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bait (0.5.2)
4
+ bait (0.5.4)
5
5
  git
6
6
  haml
7
7
  moneta
data/README.md CHANGED
@@ -118,11 +118,16 @@ bait_dir=$(dirname $0)
118
118
  project_dir="$bait_dir/.."
119
119
  cd $project_dir
120
120
 
121
- export BUNDLE_GEMFILE=$project_dir/Gemfile
121
+ export BUNDLE_GEMFILE=./Gemfile
122
122
 
123
123
  echo "bundling"
124
124
  bundle install > /dev/null 2>&1
125
- bundle exec cucumber
125
+
126
+ # The following will create screenshots and html report in report/
127
+ # It will also output to the console as usual for display in bait
128
+ SCREENSHOT_PATH=./report/ cucumber --format 'Calabash::Formatters::Html' \
129
+ --out report/index.html \
130
+ --format pretty --
126
131
  ```
127
132
 
128
133
  #### Other Projects
data/Rakefile CHANGED
@@ -38,23 +38,24 @@ def git_dirty?
38
38
  end
39
39
 
40
40
  namespace :gem do
41
- task :build => 'assets:precompile' do
41
+ task :build do
42
42
  `bundle install`
43
- if git_dirty?
44
- puts "dirty! commit first before building"
43
+ if !git_master?
44
+ puts "I'll only build the gem on the master branch"
45
45
  else
46
- if git_master?
47
- puts "On master branch"
48
- `rspec spec`
49
- if $?.exitstatus == 0
50
- puts "Specs pass. you're ready"
51
- puts `gem build bait.gemspec`
52
- puts "Done! You can gem push that now"
53
- else
54
- puts "Uhh.. you have failing specs -- not building the gem"
55
- end
46
+ puts "On master branch"
47
+ `rspec spec`
48
+ if $?.exitstatus != 0
49
+ puts "Uhh.. you have failing specs -- not building the gem"
56
50
  else
57
- puts "I'll only build the gem on the master branch"
51
+ puts "Specs pass. you're ready"
52
+ Rake::Task['assets:precompile'].invoke
53
+ if git_dirty?
54
+ puts "Dirty working tree! Commit first before building!"
55
+ exit
56
+ end
57
+ puts `gem build bait.gemspec`
58
+ puts "Done! You can gem push that now"
58
59
  end
59
60
  end
60
61
  end
data/VERSION CHANGED
@@ -1,3 +1,3 @@
1
- 0.5.2
1
+ 0.5.4
2
2
 
3
3
 
data/app/js/build.coffee CHANGED
@@ -47,6 +47,12 @@ window.Build =
47
47
  $('ul#builds').append html
48
48
  Build.DOM.init build.id
49
49
 
50
+ SimpleCov:
51
+ url: (id) ->
52
+ "/build/#{id}/coverage/index.html"
53
+ text: (truthy) ->
54
+ if truthy then "Coverage" else ""
55
+
50
56
  to_html: (build) ->
51
57
  """
52
58
  <li id="#{build.id}" class="build">
@@ -54,6 +60,9 @@ window.Build =
54
60
  <div class="status">#{build.status}</div>
55
61
  <a href="#{build.clone_url}">#{build.name}</a>
56
62
  <div class="ref">#{build.ref?=''}</div>
63
+ <a href="#{Build.SimpleCov.url(build.id)}"
64
+ class="simplecov">
65
+ #{Build.SimpleCov.text(build.simplecov)}</a>
57
66
  </div>
58
67
  <div class="output">
59
68
  <pre>#{build.output}</pre>
data/app/js/main.coffee CHANGED
@@ -20,3 +20,7 @@ Zepto ($) ->
20
20
  header.attr "class", "header #{text}"
21
21
  remove: (id) ->
22
22
  Build.find(id).remove()
23
+ simplecov: (id, supported) ->
24
+ link = Build.find(id).find('.simplecov')
25
+ link.attr 'href', Build.SimpleCov.url(id)
26
+ link.text Build.SimpleCov.text(supported)
@@ -9,7 +9,7 @@ window.ManualClone =
9
9
  if not button.attr('disabled')
10
10
  button.attr('disabled', 'disabled')
11
11
  $.post '/build/create', {clone_url: input}, (response) ->
12
- console.log response
12
+ field.val('')
13
13
  button.removeAttr('disabled')
14
14
  else
15
15
  alert "Enter a local path or remote url to a git repo, e.g.:\n
data/bin/bait CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- ENV['RACK_ENV'] = 'production'
2
+ ENV['RACK_ENV'] ||= 'production'
3
3
  require 'rubygems'
4
4
  require 'bait/cli'
5
5
  Bait::CLI.send(ARGV[0] || :server)
data/lib/bait/api.rb CHANGED
@@ -6,9 +6,15 @@ require 'json'
6
6
  require 'bait/pubsub'
7
7
  require 'bait/build'
8
8
 
9
- unless Bait.env == "production"
10
- require 'sinatra/asset_snack'
9
+ if Bait.env != "production"
10
+ require 'sinatra/asset_snack'
11
11
  DYNAMIC_ASSETS = true
12
+ require 'fileutils'
13
+ public = File.join File.dirname(__FILE__), %w(public)
14
+ [%w(js application.js), %w(css application.css)].each do |i|
15
+ path = File.join(public, i)
16
+ FileUtils.rm(path) if File.exists?(path)
17
+ end
12
18
  end
13
19
 
14
20
  module Bait
@@ -72,5 +78,14 @@ module Bait
72
78
  end
73
79
  end
74
80
  end
81
+
82
+ ##
83
+ # SimpleCov Passthrough
84
+ get '/build/:id/coverage/*' do
85
+ build = Build.find params[:id]
86
+ if build.simplecov
87
+ send_file File.join(build.coverage_dir, params[:splat])
88
+ end
89
+ end
75
90
  end
76
91
  end
data/lib/bait/build.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'bait/object'
2
2
  require 'bait/tester'
3
3
  require 'bait/build_helper'
4
+ require 'bait/simplecov_support'
4
5
  require 'bait/pubsub'
5
6
  require 'bait/phase'
6
7
  require 'json'
@@ -8,10 +9,12 @@ require 'json'
8
9
  module Bait
9
10
  class Build < Bait::Object
10
11
  include Bait::BuildHelper
12
+ include Bait::SimpleCovSupport
11
13
 
12
14
  adapter :memory,
13
15
  Moneta.new(:YAML, :file => Bait.db_file('builds'))
14
16
 
17
+ attribute :simplecov, Boolean, default: false
15
18
  attribute :ref, String
16
19
  attribute :owner_name, String
17
20
  attribute :owner_email, String
@@ -60,7 +63,7 @@ module Bait
60
63
  end
61
64
  self.save
62
65
  self.broadcast(:status, self.status)
63
- # good place to check for a coverage report
66
+ check_for_simplecov
64
67
  end.run!
65
68
  end
66
69
 
data/lib/bait/cli.rb CHANGED
@@ -25,7 +25,10 @@ module Bait
25
25
  puts "Run 'bait init' to create it"
26
26
  exit 1
27
27
  else
28
- system(script)
28
+ system script
29
+ status = $?.exitstatus
30
+ puts "exited with status #{status}"
31
+ exit status
29
32
  end
30
33
  end
31
34
 
@@ -81,8 +81,20 @@
81
81
  return Build.DOM.init(build.id);
82
82
  }
83
83
  },
84
+ SimpleCov: {
85
+ url: function(id) {
86
+ return "/build/" + id + "/coverage/index.html";
87
+ },
88
+ text: function(truthy) {
89
+ if (truthy) {
90
+ return "Coverage";
91
+ } else {
92
+ return "";
93
+ }
94
+ }
95
+ },
84
96
  to_html: function(build) {
85
- return "<li id=\"" + build.id + "\" class=\"build\">\n <div class=\"header " + build.status + "\">\n <div class=\"status\">" + build.status + "</div>\n <a href=\"" + build.clone_url + "\">" + build.name + "</a>\n <div class=\"ref\">" + (build.ref != null ? build.ref : build.ref = '') + "</div>\n </div>\n <div class=\"output\">\n <pre>" + build.output + "</pre>\n </div>\n <div class=\"actions\">\n <a href=\"#\" class=\"remove\" data-url=\"/build/" + build.id + "\">Remove</a>\n |\n <a href=\"#\" class=\"retest\" data-url=\"/build/" + build.id + "/retest\">Retest</a>\n </div>\n</li>";
97
+ return "<li id=\"" + build.id + "\" class=\"build\">\n <div class=\"header " + build.status + "\">\n <div class=\"status\">" + build.status + "</div>\n <a href=\"" + build.clone_url + "\">" + build.name + "</a>\n <div class=\"ref\">" + (build.ref != null ? build.ref : build.ref = '') + "</div>\n <a href=\"" + (Build.SimpleCov.url(build.id)) + "\"\n class=\"simplecov\">\n " + (Build.SimpleCov.text(build.simplecov)) + "</a>\n </div>\n <div class=\"output\">\n <pre>" + build.output + "</pre>\n </div>\n <div class=\"actions\">\n <a href=\"#\" class=\"remove\" data-url=\"/build/" + build.id + "\">Remove</a>\n |\n <a href=\"#\" class=\"retest\" data-url=\"/build/" + build.id + "/retest\">Retest</a>\n </div>\n</li>";
86
98
  }
87
99
  };
88
100
 
@@ -120,6 +132,12 @@
120
132
  },
121
133
  remove: function(id) {
122
134
  return Build.find(id).remove();
135
+ },
136
+ simplecov: function(id, supported) {
137
+ var link;
138
+ link = Build.find(id).find('.simplecov');
139
+ link.attr('href', Build.SimpleCov.url(id));
140
+ return link.text(Build.SimpleCov.text(supported));
123
141
  }
124
142
  }
125
143
  });
@@ -146,7 +164,7 @@
146
164
  return $.post('/build/create', {
147
165
  clone_url: input
148
166
  }, function(response) {
149
- console.log(response);
167
+ field.val('');
150
168
  return button.removeAttr('disabled');
151
169
  });
152
170
  }
@@ -0,0 +1,30 @@
1
+ module Bait
2
+ module SimpleCovSupport
3
+ def coverage_dir
4
+ File.join(clone_path, 'coverage')
5
+ end
6
+
7
+ def simplecov_html_path
8
+ File.join(coverage_dir, "index.html")
9
+ end
10
+
11
+ def check_for_simplecov
12
+ if File.exists? simplecov_html_path
13
+ self.simplecov = true
14
+ convert_paths
15
+ self.broadcast :simplecov, 'supported'
16
+ self.save
17
+ end
18
+ end
19
+
20
+ def convert_paths
21
+ buffer = ""
22
+ File.open(simplecov_html_path, "r") do |file|
23
+ buffer = file.read.gsub("./assets", "/build/#{self.id}/coverage/assets")
24
+ end
25
+ File.open(simplecov_html_path, "w") do |file|
26
+ file.write buffer
27
+ end
28
+ end
29
+ end
30
+ end
@@ -134,4 +134,18 @@ describe Bait::Api do
134
134
  last_response.content_type.should match(/text\/event-stream/)
135
135
  end
136
136
  end
137
+
138
+ describe "GET /build/:id/coverage/index.html" do
139
+ before do
140
+ @build = Bait::Build.create(name: "quickfox", clone_url:'...')
141
+ FileUtils.mkdir_p File.dirname @build.simplecov_html_path
142
+ File.open(@build.simplecov_html_path, "w") {|f| f.puts "test string" }
143
+ @build.simplecov = true
144
+ @build.save
145
+ get "/build/#{@build.id}/coverage/index.html"
146
+ end
147
+ it "renders the file" do
148
+ last_response.body.strip.should eq "test string"
149
+ end
150
+ end
137
151
  end
@@ -103,4 +103,34 @@ describe Bait::Build do
103
103
  Dir.exists?(build.sandbox_directory).should be_false
104
104
  end
105
105
  end
106
+
107
+ describe "simplecov support" do
108
+ context 'has simplecov files' do
109
+ before do
110
+ FileUtils.mkdir_p File.dirname build.simplecov_html_path
111
+ FileUtils.touch build.simplecov_html_path
112
+ end
113
+ it "sends an event that it discovered simplecov" do
114
+ Bait.should_receive(:broadcast).with(:build, :simplecov, build.id, 'supported')
115
+ build.check_for_simplecov
116
+ end
117
+ it "sets the simplecov flag to true" do
118
+ build.reload.simplecov.should be_false
119
+ build.check_for_simplecov
120
+ build.reload.simplecov.should be_true
121
+ end
122
+ end
123
+
124
+ context 'has no simplecov files' do
125
+ before { build }
126
+ it "does not broadcast a simplecov supported message" do
127
+ Bait.should_not_receive(:broadcast).with(:build, :simplecov, build.id, 'supported')
128
+ build.check_for_simplecov
129
+ end
130
+ it "does not set the simplecov flag to true" do
131
+ build.check_for_simplecov
132
+ build.reload.simplecov.should be_false
133
+ end
134
+ end
135
+ end
106
136
  end
@@ -6,12 +6,6 @@ describe Bait::Tester do
6
6
  let(:tester) { Bait::Tester.new }
7
7
 
8
8
  describe "#perform" do
9
- shared_examples_for "a test run" do
10
- it "saves output into the build" do
11
- build.reload.output.should match "this is a test script"
12
- end
13
- end
14
-
15
9
  subject { build.reload }
16
10
  before { build.clone! }
17
11
 
@@ -45,6 +39,13 @@ describe Bait::Tester do
45
39
  write_script_with_status build.script('test'), status
46
40
  tester.perform build.id
47
41
  end
42
+
43
+ shared_examples_for "a test run" do
44
+ it "saves output into the build" do
45
+ build.reload.output.should match "this is a test script"
46
+ end
47
+ end
48
+
48
49
  context "successful" do
49
50
  let(:status) { 0 }
50
51
  it { should be_passed }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bait
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keyvan Fatehi
@@ -274,12 +274,13 @@ files:
274
274
  - lib/bait/public/js/zepto.min.js
275
275
  - lib/bait/pubsub.rb
276
276
  - lib/bait/simple_query.rb
277
+ - lib/bait/simplecov_support.rb
277
278
  - lib/bait/tester.rb
278
279
  - lib/bait/version.rb
279
280
  - lib/bait/views/builds.haml
280
281
  - lib/bait/views/layout.haml
281
282
  - spec/lib/bait/analyzer_spec.rb
282
- - spec/lib/bait/app/api_spec.rb
283
+ - spec/lib/bait/api_spec.rb
283
284
  - spec/lib/bait/build_spec.rb
284
285
  - spec/lib/bait/pubsub_spec.rb
285
286
  - spec/lib/bait/tester_spec.rb
@@ -312,7 +313,7 @@ specification_version: 4
312
313
  summary: build and integration test service
313
314
  test_files:
314
315
  - spec/lib/bait/analyzer_spec.rb
315
- - spec/lib/bait/app/api_spec.rb
316
+ - spec/lib/bait/api_spec.rb
316
317
  - spec/lib/bait/build_spec.rb
317
318
  - spec/lib/bait/pubsub_spec.rb
318
319
  - spec/lib/bait/tester_spec.rb