starting_blocks 0.1.1 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,31 +1,35 @@
1
1
  module StartingBlocks
2
2
  class ResultParser
3
- def parse(text)
4
- @text = text
5
- {
6
- tests: greater_of([tests, runs]),
7
- assertions: assertions,
8
- failures: failures,
9
- errors: errors,
10
- skips: skips
11
- }
3
+
4
+ def parse text
5
+ output = load_the_output_from text
6
+ output[:color] = color
7
+ output
12
8
  end
13
9
 
14
10
  private
15
11
 
16
- def method_missing(meth, *args, &blk)
17
- get_count_of meth.to_s
12
+ def color
13
+ return :red unless tests_exist?
14
+ return :red if problems_exist?
15
+ return :yellow if skips_exist?
16
+ :green
17
+ end
18
+
19
+ def load_the_output_from text
20
+ @output = StartingBlocks::ResultTextParser.new.parse text
18
21
  end
19
22
 
20
- def get_count_of name
21
- @text.scan(/(\d+ #{name})/)[-1][0].split(' ')[0].to_i
22
- rescue
23
- 0
23
+ def tests_exist?
24
+ (@output[:tests] || 0) > 0
24
25
  end
25
26
 
26
- def greater_of values
27
- values.sort_by { |x| x }.last
27
+ def problems_exist?
28
+ ((@output[:errors] || 0) > 0) or ((@output[:failures] || 0) > 0)
29
+ end
30
+
31
+ def skips_exist?
32
+ (@output[:skips] || 0) > 0
28
33
  end
29
34
  end
30
35
  end
31
-
@@ -0,0 +1,31 @@
1
+ module StartingBlocks
2
+ class ResultTextParser
3
+ def parse(text)
4
+ @text = text
5
+ {
6
+ tests: greater_of([tests, runs]),
7
+ assertions: assertions,
8
+ failures: failures,
9
+ errors: errors,
10
+ skips: skips
11
+ }
12
+ end
13
+
14
+ private
15
+
16
+ def method_missing(meth, *args, &blk)
17
+ get_count_of meth.to_s
18
+ end
19
+
20
+ def get_count_of name
21
+ @text.scan(/(\d+ #{name})/)[-1][0].split(' ')[0].to_i
22
+ rescue
23
+ 0
24
+ end
25
+
26
+ def greater_of values
27
+ values.sort_by { |x| x }.last
28
+ end
29
+ end
30
+ end
31
+
@@ -1,3 +1,3 @@
1
1
  module StartingBlocks
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -3,6 +3,7 @@ require_relative 'starting_blocks/displayable'
3
3
  require_relative 'starting_blocks/runner'
4
4
  require_relative 'starting_blocks/watcher'
5
5
  require_relative 'starting_blocks/result_parser'
6
+ require_relative 'starting_blocks/result_text_parser'
6
7
  require_relative 'starting_blocks/publisher'
7
8
  #require_relative 'extensions/blinky'
8
9
 
@@ -1,115 +1,73 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe StartingBlocks::ResultParser do
4
- describe "simple case" do
5
- let(:text) do <<EOF
6
- Fabulous tests in 0.000372s, 2688.1720 tests/s, 2688.1720 assertions/s.
7
4
 
8
- 2 tests, 3 assertions, 4 failures, 5 errors, 6 skips
5
+ let(:parsed_output) { {} }
9
6
 
10
- asldkjflaskjflsakj
11
- EOF
12
- end
13
-
14
- let(:expected_results) do
15
- {
16
- tests: 2,
17
- assertions: 3,
18
- failures: 4,
19
- errors: 5,
20
- skips: 6
21
- }
22
- end
7
+ let(:output) do
8
+ text = Object.new
9
+ text_parser = Object.new
23
10
 
24
- def subject
25
- StartingBlocks::ResultParser.new
26
- end
11
+ StartingBlocks::ResultTextParser.stubs(:new).returns text_parser
12
+ text_parser.stubs(:parse).with(text).returns parsed_output
27
13
 
28
- it "should return the counts" do
29
- subject.parse(text).contrast_with! expected_results
30
- end
14
+ StartingBlocks::ResultParser.new.parse text
31
15
  end
32
16
 
33
- describe "another case" do
34
- let(:text) do <<EOF
35
- aaaaa
36
- 801 tests, 30014 assertions, 432 failures, 234 errors, 2141 skips
37
- bbbbbb
38
- EOF
39
- end
40
-
41
- let(:expected_results) do
42
- {
43
- tests: 801,
44
- assertions: 30014,
45
- failures: 432,
46
- errors: 234,
47
- skips: 2141
48
- }
49
- end
50
-
51
- def subject
52
- StartingBlocks::ResultParser.new
53
- end
54
-
55
- it "should return the counts" do
56
- subject.parse(text).contrast_with! expected_results
57
- end
17
+ it "should return the result from the text parser" do
18
+ output.must_be_same_as parsed_output
58
19
  end
59
20
 
60
- describe "unparsable text" do
61
- let(:text) do <<EOF
62
- aaaaa
63
- lkjsdlfkjslkjslkjalskjfsalkjfd
64
- bbbbbb
65
- EOF
66
- end
67
-
68
- let(:expected_results) do
69
- {
70
- tests: 0,
71
- assertions: 0,
72
- failures: 0,
73
- errors: 0,
74
- skips: 0
75
- }
76
- end
21
+ describe "different output scenarios" do
22
+
23
+ [:tests, :skips].to_objects {[
24
+ [9, 1], [10, 2], [10, 3]
25
+ ]}.each do |test|
26
+ describe "yellow" do
27
+ it "should have tests and skips" do
28
+ parsed_output[:tests] = test.tests
29
+ parsed_output[:skips] = test.skips
30
+ output[:color].must_equal :yellow
31
+ end
32
+ end
33
+ end
34
+
35
+ [:tests, :failures, :errors, :skips].to_objects {[
36
+ [1, 1, nil, nil],
37
+ [2, nil, 1, nil],
38
+ [3, nil, 2, 0],
39
+ [4, 3, nil, 0],
40
+ ]}.each do |test|
41
+ describe "red" do
42
+ it "should return red" do
43
+ parsed_output[:tests] = test.tests
44
+ parsed_output[:failures] = test.failures
45
+ parsed_output[:errors] = test.errors
46
+ parsed_output[:skips] = test.skips
47
+ output[:color].must_equal :red
48
+ end
49
+ end
50
+ end
51
+
52
+ [:tests, :failures, :errors, :skips].to_objects {[
53
+ [1, nil, nil, nil],
54
+ [2, 0, nil, nil],
55
+ [3, nil, 0, nil],
56
+ [4, nil, nil, 0],
57
+ ]}.each do |test|
58
+
59
+ describe "green" do
60
+ it "should set the color to red if there are tests and failures" do
61
+ parsed_output[:tests] = test.tests
62
+ parsed_output[:failures] = test.failures
63
+ parsed_output[:errors] = test.errors
64
+ parsed_output[:skips] = test.skips
65
+ output[:color].must_equal :green
66
+ end
67
+ end
77
68
 
78
- def subject
79
- StartingBlocks::ResultParser.new
80
69
  end
81
70
 
82
- it "should return the counts" do
83
- subject.parse(text).contrast_with! expected_results
84
- end
85
71
  end
86
72
 
87
- describe "simple case, minitest 5.0" do
88
- let(:text) do <<EOF
89
- Fabulous run in 0.000372s, 2688.1720 runs/s, 2688.1720 assertions/s.
90
-
91
- 2 runs, 3 assertions, 4 failures, 5 errors, 6 skips
92
-
93
- asldkjflaskjflsakj
94
- EOF
95
- end
96
-
97
- let(:expected_results) do
98
- {
99
- tests: 2,
100
- assertions: 3,
101
- failures: 4,
102
- errors: 5,
103
- skips: 6
104
- }
105
- end
106
-
107
- def subject
108
- StartingBlocks::ResultParser.new
109
- end
110
-
111
- it "should return the counts" do
112
- subject.parse(text).contrast_with! expected_results
113
- end
114
- end
115
73
  end
@@ -0,0 +1,115 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe StartingBlocks::ResultTextParser do
4
+ describe "simple case" do
5
+ let(:text) do <<EOF
6
+ Fabulous tests in 0.000372s, 2688.1720 tests/s, 2688.1720 assertions/s.
7
+
8
+ 2 tests, 3 assertions, 4 failures, 5 errors, 6 skips
9
+
10
+ asldkjflaskjflsakj
11
+ EOF
12
+ end
13
+
14
+ let(:expected_results) do
15
+ {
16
+ tests: 2,
17
+ assertions: 3,
18
+ failures: 4,
19
+ errors: 5,
20
+ skips: 6
21
+ }
22
+ end
23
+
24
+ def subject
25
+ StartingBlocks::ResultTextParser.new
26
+ end
27
+
28
+ it "should return the counts" do
29
+ subject.parse(text).contrast_with! expected_results
30
+ end
31
+ end
32
+
33
+ describe "another case" do
34
+ let(:text) do <<EOF
35
+ aaaaa
36
+ 801 tests, 30014 assertions, 432 failures, 234 errors, 2141 skips
37
+ bbbbbb
38
+ EOF
39
+ end
40
+
41
+ let(:expected_results) do
42
+ {
43
+ tests: 801,
44
+ assertions: 30014,
45
+ failures: 432,
46
+ errors: 234,
47
+ skips: 2141
48
+ }
49
+ end
50
+
51
+ def subject
52
+ StartingBlocks::ResultTextParser.new
53
+ end
54
+
55
+ it "should return the counts" do
56
+ subject.parse(text).contrast_with! expected_results
57
+ end
58
+ end
59
+
60
+ describe "unparsable text" do
61
+ let(:text) do <<EOF
62
+ aaaaa
63
+ lkjsdlfkjslkjslkjalskjfsalkjfd
64
+ bbbbbb
65
+ EOF
66
+ end
67
+
68
+ let(:expected_results) do
69
+ {
70
+ tests: 0,
71
+ assertions: 0,
72
+ failures: 0,
73
+ errors: 0,
74
+ skips: 0
75
+ }
76
+ end
77
+
78
+ def subject
79
+ StartingBlocks::ResultTextParser.new
80
+ end
81
+
82
+ it "should return the counts" do
83
+ subject.parse(text).contrast_with! expected_results
84
+ end
85
+ end
86
+
87
+ describe "simple case, minitest 5.0" do
88
+ let(:text) do <<EOF
89
+ Fabulous run in 0.000372s, 2688.1720 runs/s, 2688.1720 assertions/s.
90
+
91
+ 2 runs, 3 assertions, 4 failures, 5 errors, 6 skips
92
+
93
+ asldkjflaskjflsakj
94
+ EOF
95
+ end
96
+
97
+ let(:expected_results) do
98
+ {
99
+ tests: 2,
100
+ assertions: 3,
101
+ failures: 4,
102
+ errors: 5,
103
+ skips: 6
104
+ }
105
+ end
106
+
107
+ def subject
108
+ StartingBlocks::ResultTextParser.new
109
+ end
110
+
111
+ it "should return the counts" do
112
+ subject.parse(text).contrast_with! expected_results
113
+ end
114
+ end
115
+ end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starting_blocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Darren Cauthon
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-02-20 00:00:00.000000000 Z
12
+ date: 2014-02-28 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,81 +30,92 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: contrast
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: subtle
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - '>='
67
+ - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
69
  version: '0'
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - '>='
75
+ - - ! '>='
67
76
  - !ruby/object:Gem::Version
68
77
  version: '0'
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: mocha
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
- - - '>='
83
+ - - ! '>='
74
84
  - !ruby/object:Gem::Version
75
85
  version: '0'
76
86
  type: :development
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
- - - '>='
91
+ - - ! '>='
81
92
  - !ruby/object:Gem::Version
82
93
  version: '0'
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: coveralls
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
- - - '>='
99
+ - - ! '>='
88
100
  - !ruby/object:Gem::Version
89
101
  version: '0'
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
- - - '>='
107
+ - - ! '>='
95
108
  - !ruby/object:Gem::Version
96
109
  version: '0'
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: listen
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
115
  - - ~>
102
116
  - !ruby/object:Gem::Version
103
117
  version: 1.3.1
104
- - - '>='
118
+ - - ! '>='
105
119
  - !ruby/object:Gem::Version
106
120
  version: '1.0'
107
121
  - - <
@@ -110,11 +124,12 @@ dependencies:
110
124
  type: :runtime
111
125
  prerelease: false
112
126
  version_requirements: !ruby/object:Gem::Requirement
127
+ none: false
113
128
  requirements:
114
129
  - - ~>
115
130
  - !ruby/object:Gem::Version
116
131
  version: 1.3.1
117
- - - '>='
132
+ - - ! '>='
118
133
  - !ruby/object:Gem::Version
119
134
  version: '1.0'
120
135
  - - <
@@ -139,40 +154,50 @@ files:
139
154
  - lib/starting_blocks/displayable.rb
140
155
  - lib/starting_blocks/publisher.rb
141
156
  - lib/starting_blocks/result_parser.rb
157
+ - lib/starting_blocks/result_text_parser.rb
142
158
  - lib/starting_blocks/runner.rb
143
159
  - lib/starting_blocks/version.rb
144
160
  - lib/starting_blocks/watcher.rb
145
161
  - spec/spec_helper.rb
146
162
  - spec/starting_blocks/publisher_spec.rb
147
163
  - spec/starting_blocks/result_parser_spec.rb
164
+ - spec/starting_blocks/result_text_parser_spec.rb
148
165
  - spec/starting_blocks/runner_spec.rb
149
166
  - starting_blocks.gemspec
150
167
  homepage: http://www.github.com/darrencauthon/starting_blocks
151
168
  licenses:
152
169
  - MIT
153
- metadata: {}
154
170
  post_install_message:
155
171
  rdoc_options: []
156
172
  require_paths:
157
173
  - lib
158
174
  required_ruby_version: !ruby/object:Gem::Requirement
175
+ none: false
159
176
  requirements:
160
- - - '>='
177
+ - - ! '>='
161
178
  - !ruby/object:Gem::Version
162
179
  version: '0'
180
+ segments:
181
+ - 0
182
+ hash: 4386760652791413549
163
183
  required_rubygems_version: !ruby/object:Gem::Requirement
184
+ none: false
164
185
  requirements:
165
- - - '>='
186
+ - - ! '>='
166
187
  - !ruby/object:Gem::Version
167
188
  version: '0'
189
+ segments:
190
+ - 0
191
+ hash: 4386760652791413549
168
192
  requirements: []
169
193
  rubyforge_project:
170
- rubygems_version: 2.1.11
194
+ rubygems_version: 1.8.25
171
195
  signing_key:
172
- specification_version: 4
196
+ specification_version: 3
173
197
  summary: One command to run all tests, test watcher, etc.
174
198
  test_files:
175
199
  - spec/spec_helper.rb
176
200
  - spec/starting_blocks/publisher_spec.rb
177
201
  - spec/starting_blocks/result_parser_spec.rb
202
+ - spec/starting_blocks/result_text_parser_spec.rb
178
203
  - spec/starting_blocks/runner_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 0092771c3a1d485458ee8630785cec97d8c38562
4
- data.tar.gz: cb8947d7f7289a9c6556914b6f36fb1a11c8b3d7
5
- SHA512:
6
- metadata.gz: d9d602d1547d3069d00be55727001d6ab5379664516bd9f5403858254982fddfad2b9214c6f9032ea422c61c127b0d12e955907cb2e776a42cbce22dcdf0ff26
7
- data.tar.gz: 2e85f93c2f4089e740bf86d258ee9772f46da343105c43a693bece4b06638b448c508da262eff72d51e0029e1d96e0cd7e48fd37b7eaf522fa54f435bba16676