starting_blocks 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -18
- data/lib/starting_blocks/bash.rb +13 -0
- data/lib/starting_blocks/bash_publisher.rb +11 -0
- data/lib/starting_blocks/minitest_contract.rb +2 -2
- data/lib/starting_blocks/pass_through_result_builder.rb +11 -0
- data/lib/starting_blocks/publisher.rb +14 -8
- data/lib/starting_blocks/{result_parser.rb → result_builder.rb} +9 -6
- data/lib/starting_blocks/runner.rb +0 -1
- data/lib/starting_blocks/{result_text_parser.rb → text_parser.rb} +1 -2
- data/lib/starting_blocks/version.rb +1 -1
- data/lib/starting_blocks/watcher.rb +1 -1
- data/lib/starting_blocks.rb +18 -10
- data/spec/starting_blocks/publisher_spec.rb +3 -3
- data/spec/starting_blocks/{result_parser_spec.rb → result_builder_spec.rb} +33 -7
- data/spec/starting_blocks/runner_spec.rb +0 -3
- data/spec/starting_blocks/{result_text_parser_spec.rb → text_parser_spec.rb} +5 -5
- metadata +11 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ce4e880814c71fa1c9174d5cd5434ea103adf95
|
4
|
+
data.tar.gz: 0a161dd6c02163a8af232282868e8f64dbdf5b1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a805f694449086284b027a891c9801d8e5f5b6a49845ec712b3eb5baa361926ba620e244ab7722ce792bbd085fc9faa0c2112c850e3b987c91f66b626b73c5bf
|
7
|
+
data.tar.gz: 00f70b03454fad00d7323e33d0826b76547e96c03328202a2480d5db3afe4b76994ecd366177b10c67228f8cb9d3a838758a1a70859f5c4e271b296c4e3663e5
|
data/README.md
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
# Starting Blocks
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/darrencauthon/starting_blocks.png?branch=master)](https://travis-ci.org/darrencauthon/starting_blocks)
|
4
|
-
[![Code Climate](https://codeclimate.com/github/darrencauthon/starting_blocks.png)](https://codeclimate.com/github/darrencauthon/starting_blocks)
|
5
|
-
[![Coverage Status](https://coveralls.io/repos/darrencauthon/subtle/badge.png?branch=master)](https://coveralls.io/r/darrencauthon/starting_blocks)
|
6
|
-
|
7
3
|
## Why?
|
8
4
|
|
9
5
|
The purpose of this gem is to run my Minitest specs, with no hassle. No Rakefile updates, no Gemfile/gemspec installs, and no regex Guard files.
|
@@ -35,25 +31,40 @@ sb
|
|
35
31
|
Run the tests in any test or spec file after it is saved. Will also run the specs for any file that has a matching test or spec file:
|
36
32
|
|
37
33
|
````
|
38
|
-
sb
|
34
|
+
sb watch
|
35
|
+
````
|
36
|
+
|
37
|
+
Run any arbitrary command through starting blocks. The results of the statement (notably the success or failure determined by the exit code) will be published through your starting blocks plugins.
|
38
|
+
|
39
|
+
````
|
40
|
+
sb execute "git push heroku master"
|
39
41
|
````
|
40
42
|
|
43
|
+
## Plugins
|
44
|
+
|
45
|
+
### Blinky Light
|
41
46
|
Turn your [blinky light](https://github.com/perryn/blinky) red/yellow/green based on the results of your test run:
|
42
47
|
|
43
48
|
````
|
44
|
-
|
49
|
+
gem install starting_blocks-blinky
|
50
|
+
sb blinky
|
45
51
|
````
|
46
52
|
|
47
|
-
|
53
|
+
### Growl
|
54
|
+
Pop a growl message based on your test results:
|
48
55
|
|
49
56
|
````
|
50
|
-
|
57
|
+
gem install starting_blocks-growl
|
58
|
+
sb growl
|
51
59
|
````
|
52
60
|
|
53
|
-
|
61
|
+
### Stopplicht
|
62
|
+
|
63
|
+
Change your stopplicht based on your test results:
|
54
64
|
|
55
65
|
````
|
56
|
-
|
66
|
+
gem install starting_blocks-stopplicht
|
67
|
+
sb growl
|
57
68
|
````
|
58
69
|
|
59
70
|
## Installation
|
@@ -61,11 +72,3 @@ sb --growl --blinky --watch
|
|
61
72
|
Install it yourself with:
|
62
73
|
|
63
74
|
$ gem install starting_blocks
|
64
|
-
|
65
|
-
If you would like to use a [blinky light](https://github.com/perryn/blinky) to show the results of your tests:
|
66
|
-
|
67
|
-
$ gem install starting_blocks-blinky
|
68
|
-
|
69
|
-
If you would like growl results of your tests:
|
70
|
-
|
71
|
-
$ gem install starting_blocks-growl
|
@@ -52,9 +52,9 @@ module StartingBlocks
|
|
52
52
|
def execute_these_files files
|
53
53
|
requires = files.map { |x| "require '#{x}'" }.join("\n")
|
54
54
|
if options[:use_bundler]
|
55
|
-
|
55
|
+
Bash.run "bundle exec ruby -e \"#{requires}\""
|
56
56
|
else
|
57
|
-
|
57
|
+
Bash.run "ruby -e \"#{requires}\""
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -1,12 +1,20 @@
|
|
1
1
|
module StartingBlocks
|
2
2
|
module Publisher
|
3
3
|
class << self
|
4
|
-
attr_accessor :subscribers, :
|
4
|
+
attr_accessor :subscribers, :result_builder
|
5
|
+
|
6
|
+
def subscribers
|
7
|
+
@subscribers ||= [BashPublisher.new]
|
8
|
+
end
|
9
|
+
|
10
|
+
def result_builder
|
11
|
+
@result_builder ||= StartingBlocks::ResultBuilder.new
|
12
|
+
end
|
5
13
|
|
6
14
|
def publish_results results
|
7
|
-
return unless
|
8
|
-
|
9
|
-
parsed_results = StartingBlocks::Publisher.
|
15
|
+
return unless subscribers
|
16
|
+
subscribers.each do |s|
|
17
|
+
parsed_results = StartingBlocks::Publisher.result_builder.build_from results
|
10
18
|
begin
|
11
19
|
s.receive_results parsed_results
|
12
20
|
rescue
|
@@ -15,8 +23,8 @@ module StartingBlocks
|
|
15
23
|
end
|
16
24
|
|
17
25
|
def publish_files_to_run files
|
18
|
-
return unless
|
19
|
-
|
26
|
+
return unless subscribers
|
27
|
+
subscribers.each do |s|
|
20
28
|
begin
|
21
29
|
s.receive_files_to_run files
|
22
30
|
rescue
|
@@ -26,5 +34,3 @@ module StartingBlocks
|
|
26
34
|
end
|
27
35
|
end
|
28
36
|
end
|
29
|
-
StartingBlocks::Publisher.subscribers = []
|
30
|
-
StartingBlocks::Publisher.result_parser = StartingBlocks::ResultParser.new
|
@@ -1,10 +1,13 @@
|
|
1
1
|
module StartingBlocks
|
2
|
-
class ResultParser
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
class ResultBuilder
|
4
|
+
|
5
|
+
def build_from run_result
|
6
|
+
load_the_output_from(run_result[:text])
|
7
|
+
.merge(color: color,
|
8
|
+
text: run_result[:text],
|
9
|
+
exit_code: run_result[:exit_code],
|
10
|
+
success: run_result[:success])
|
8
11
|
end
|
9
12
|
|
10
13
|
private
|
@@ -17,7 +20,7 @@ module StartingBlocks
|
|
17
20
|
end
|
18
21
|
|
19
22
|
def load_the_output_from text
|
20
|
-
@output = StartingBlocks::
|
23
|
+
@output = StartingBlocks::TextParser.new.parse text
|
21
24
|
end
|
22
25
|
|
23
26
|
def tests_exist?
|
@@ -89,7 +89,7 @@ module StartingBlocks
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def store_the_specs_if_they_failed results, specs
|
92
|
-
parsed_results = StartingBlocks::Publisher.
|
92
|
+
parsed_results = StartingBlocks::Publisher.result_builder.build_from results
|
93
93
|
if parsed_results[:failures] > 0 || parsed_results[:skips] > 0 || parsed_results[:errors] > 0
|
94
94
|
@last_failed_run = specs
|
95
95
|
else
|
data/lib/starting_blocks.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
|
-
|
2
|
-
require_relative
|
3
|
-
|
4
|
-
require_relative 'starting_blocks/result_parser'
|
5
|
-
require_relative 'starting_blocks/result_text_parser'
|
6
|
-
require_relative 'starting_blocks/publisher'
|
7
|
-
require_relative 'starting_blocks/cli'
|
8
|
-
require_relative 'starting_blocks/minitest_contract'
|
1
|
+
require_relative "starting_blocks/bash_publisher"
|
2
|
+
require_relative "starting_blocks/result_builder"
|
3
|
+
Dir[File.dirname(__FILE__) + '/starting_blocks/*.rb'].each { |f| require f }
|
9
4
|
|
10
5
|
module StartingBlocks
|
11
6
|
|
@@ -52,6 +47,20 @@ module StartingBlocks
|
|
52
47
|
|
53
48
|
def default_actions
|
54
49
|
{
|
50
|
+
execute: -> do
|
51
|
+
StartingBlocks::Publisher.result_builder = StartingBlocks::PassThroughResultBuilder.new
|
52
|
+
|
53
|
+
statement_to_execute = ARGV[ARGV.index('execute') + 1]
|
54
|
+
StartingBlocks::Publisher.publish_files_to_run [statement_to_execute]
|
55
|
+
result = StartingBlocks::Bash.run(statement_to_execute)
|
56
|
+
StartingBlocks::Publisher.publish_results( { color: (result[:success] ? :green : :red),
|
57
|
+
tests: 1,
|
58
|
+
assertions: 1,
|
59
|
+
failures: (result[:success] ? 0 : 1),
|
60
|
+
errors: 0,
|
61
|
+
skips: 0 })
|
62
|
+
puts result[:text]
|
63
|
+
end,
|
55
64
|
watch: -> do
|
56
65
|
listener = StartingBlocks::Watcher.start_watching Dir, StartingBlocks.options
|
57
66
|
StartingBlocks.display "Going to sleep, waiting for changes"
|
@@ -69,7 +78,7 @@ module StartingBlocks
|
|
69
78
|
end,
|
70
79
|
run_all_tests: -> do
|
71
80
|
results = run_all_specs.call
|
72
|
-
parsed_results = StartingBlocks::Publisher.
|
81
|
+
parsed_results = StartingBlocks::Publisher.result_builder.build_from results
|
73
82
|
success = parsed_results[:color] == :green
|
74
83
|
exit success
|
75
84
|
end,
|
@@ -96,4 +105,3 @@ module StartingBlocks
|
|
96
105
|
puts message if @verbose
|
97
106
|
end
|
98
107
|
end
|
99
|
-
#StartingBlocks::Publisher.subscribers << StartingBlocks::Extensions::BlinkyLighting.new
|
@@ -4,12 +4,12 @@ describe StartingBlocks::Publisher do
|
|
4
4
|
|
5
5
|
let(:results) { Object.new }
|
6
6
|
let(:parsed_results) { Object.new }
|
7
|
-
let(:
|
7
|
+
let(:result_builder) { mock() }
|
8
8
|
let(:files) { Object.new }
|
9
9
|
|
10
10
|
before do
|
11
|
-
|
12
|
-
StartingBlocks::Publisher.
|
11
|
+
result_builder.stubs(:build_from).with(results).returns parsed_results
|
12
|
+
StartingBlocks::Publisher.result_builder = result_builder
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "#publish_results" do
|
@@ -1,21 +1,47 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
|
-
describe StartingBlocks::
|
3
|
+
describe StartingBlocks::ResultBuilder do
|
4
4
|
|
5
5
|
let(:parsed_output) { {} }
|
6
|
+
let(:text) { Object.new }
|
7
|
+
let(:success) { Object.new }
|
8
|
+
let(:exit_code) { Object.new }
|
6
9
|
|
7
10
|
let(:output) do
|
8
|
-
text = Object.new
|
9
11
|
text_parser = Object.new
|
12
|
+
input = {
|
13
|
+
text: text,
|
14
|
+
success: success,
|
15
|
+
exit_code: exit_code,
|
16
|
+
}
|
10
17
|
|
11
|
-
StartingBlocks::
|
12
|
-
text_parser.stubs(:parse).
|
18
|
+
StartingBlocks::TextParser.stubs(:new).returns text_parser
|
19
|
+
text_parser.stubs(:parse).returns parsed_output
|
13
20
|
|
14
|
-
StartingBlocks::
|
21
|
+
StartingBlocks::ResultBuilder.new.build_from input
|
15
22
|
end
|
16
23
|
|
17
|
-
|
18
|
-
|
24
|
+
|
25
|
+
describe "returning results from the text parser" do
|
26
|
+
|
27
|
+
it "should return the data from the text parser" do
|
28
|
+
key, value = Object.new, Object.new
|
29
|
+
parsed_output[key] = value
|
30
|
+
output[key].must_be_same_as value
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should return the text as the text" do
|
34
|
+
output[:text].must_be_same_as text
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should return the success flag" do
|
38
|
+
output[:success].must_be_same_as success
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return the exit code" do
|
42
|
+
output[:exit_code].must_be_same_as exit_code
|
43
|
+
end
|
44
|
+
|
19
45
|
end
|
20
46
|
|
21
47
|
describe "different output scenarios" do
|
@@ -13,7 +13,6 @@ describe StartingBlocks::Runner do
|
|
13
13
|
runner.expects(:execute_these_files).with(files).returns results
|
14
14
|
StartingBlocks::Publisher.expects(:publish_files_to_run).with files
|
15
15
|
StartingBlocks::Publisher.expects(:publish_results).with results
|
16
|
-
runner.expects(:puts).with results
|
17
16
|
|
18
17
|
@results = runner.run_files files
|
19
18
|
end
|
@@ -48,7 +47,6 @@ describe StartingBlocks::Runner do
|
|
48
47
|
runner.expects(:execute_these_files).with(files).returns results
|
49
48
|
StartingBlocks::Publisher.expects(:publish_files_to_run).with files
|
50
49
|
StartingBlocks::Publisher.expects(:publish_results).with results
|
51
|
-
runner.expects(:puts).with results
|
52
50
|
|
53
51
|
@results = runner.run_files files
|
54
52
|
end
|
@@ -86,7 +84,6 @@ describe StartingBlocks::Runner do
|
|
86
84
|
runner.expects(:execute_these_files).with(files_without_vendor).returns results
|
87
85
|
StartingBlocks::Publisher.expects(:publish_files_to_run).with files_without_vendor
|
88
86
|
StartingBlocks::Publisher.expects(:publish_results).with results
|
89
|
-
runner.expects(:puts).with results
|
90
87
|
|
91
88
|
@results = runner.run_files files
|
92
89
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
|
-
describe StartingBlocks::
|
3
|
+
describe StartingBlocks::TextParser do
|
4
4
|
describe "simple case" do
|
5
5
|
let(:text) do <<EOF
|
6
6
|
Fabulous tests in 0.000372s, 2688.1720 tests/s, 2688.1720 assertions/s.
|
@@ -22,7 +22,7 @@ EOF
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def subject
|
25
|
-
StartingBlocks::
|
25
|
+
StartingBlocks::TextParser.new
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should return the counts" do
|
@@ -49,7 +49,7 @@ EOF
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def subject
|
52
|
-
StartingBlocks::
|
52
|
+
StartingBlocks::TextParser.new
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should return the counts" do
|
@@ -76,7 +76,7 @@ EOF
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def subject
|
79
|
-
StartingBlocks::
|
79
|
+
StartingBlocks::TextParser.new
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should return the counts" do
|
@@ -105,7 +105,7 @@ EOF
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def subject
|
108
|
-
StartingBlocks::
|
108
|
+
StartingBlocks::TextParser.new
|
109
109
|
end
|
110
110
|
|
111
111
|
it "should return the counts" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starting_blocks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Cauthon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -110,19 +110,22 @@ files:
|
|
110
110
|
- Rakefile
|
111
111
|
- bin/sb
|
112
112
|
- lib/starting_blocks.rb
|
113
|
+
- lib/starting_blocks/bash.rb
|
114
|
+
- lib/starting_blocks/bash_publisher.rb
|
113
115
|
- lib/starting_blocks/cli.rb
|
114
116
|
- lib/starting_blocks/minitest_contract.rb
|
117
|
+
- lib/starting_blocks/pass_through_result_builder.rb
|
115
118
|
- lib/starting_blocks/publisher.rb
|
116
|
-
- lib/starting_blocks/
|
117
|
-
- lib/starting_blocks/result_text_parser.rb
|
119
|
+
- lib/starting_blocks/result_builder.rb
|
118
120
|
- lib/starting_blocks/runner.rb
|
121
|
+
- lib/starting_blocks/text_parser.rb
|
119
122
|
- lib/starting_blocks/version.rb
|
120
123
|
- lib/starting_blocks/watcher.rb
|
121
124
|
- spec/spec_helper.rb
|
122
125
|
- spec/starting_blocks/publisher_spec.rb
|
123
|
-
- spec/starting_blocks/
|
124
|
-
- spec/starting_blocks/result_text_parser_spec.rb
|
126
|
+
- spec/starting_blocks/result_builder_spec.rb
|
125
127
|
- spec/starting_blocks/runner_spec.rb
|
128
|
+
- spec/starting_blocks/text_parser_spec.rb
|
126
129
|
- spec/starting_blocks/watcher_spec.rb
|
127
130
|
- starting_blocks.gemspec
|
128
131
|
homepage: http://www.github.com/darrencauthon/starting_blocks
|
@@ -152,7 +155,7 @@ summary: One command to run all tests, test watcher, etc.
|
|
152
155
|
test_files:
|
153
156
|
- spec/spec_helper.rb
|
154
157
|
- spec/starting_blocks/publisher_spec.rb
|
155
|
-
- spec/starting_blocks/
|
156
|
-
- spec/starting_blocks/result_text_parser_spec.rb
|
158
|
+
- spec/starting_blocks/result_builder_spec.rb
|
157
159
|
- spec/starting_blocks/runner_spec.rb
|
160
|
+
- spec/starting_blocks/text_parser_spec.rb
|
158
161
|
- spec/starting_blocks/watcher_spec.rb
|