Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring; created new ragger abstraction to convert output to red/…
…amber/green
- Loading branch information
Showing
12 changed files
with
109 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
stub_runner | ||
|
||
differ_service | ||
ragger_service | ||
runner_service | ||
storer_service | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require_relative '../../lib/nearest_ancestors' | ||
|
||
class RaggerService | ||
|
||
def initialize(parent) | ||
@parent = parent | ||
end | ||
|
||
attr_reader :parent | ||
|
||
def colour(kata, output) | ||
manifest = storer.kata_manifest(kata.id) | ||
# before or after start-points re-architecture? | ||
src = manifest['red_amber_green'] | ||
if src.nil? # before | ||
unit_test_framework = manifest['unit_test_framework'] | ||
OutputColour.of(unit_test_framework, output) | ||
else # after | ||
colour = eval(src.join("\n")) | ||
colour.call(output).to_s | ||
end | ||
end | ||
|
||
private | ||
|
||
include NearestAncestors | ||
def storer; nearest_ancestors(:storer); end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require_relative './app_lib_test_base' | ||
|
||
class RaggerServiceTest < AppLibTestBase | ||
|
||
def setup | ||
super | ||
set_storer_class('FakeStorer') | ||
set_runner_class('StubRunner') | ||
end | ||
|
||
# - - - - - - - - - - - - - - - - - - - - - - - | ||
|
||
test '182F5B', | ||
'before start-points volume re-architecture', | ||
'colour of output is determined by OutputColour.of()' do | ||
kata_id = '182F5B1E68' | ||
manifest = make_manifest(kata_id) | ||
manifest['unit_test_framework'] = 'junit' | ||
storer.create_kata(manifest) | ||
kata = katas[kata_id] | ||
assert_equal 'red', ragger.colour(kata, red_output) | ||
end | ||
|
||
# - - - - - - - - - - - - - - - - - - - - - - - | ||
|
||
test '1821E3', | ||
'after start-points volume re-architecture', | ||
'colour of output is determined by red-amber-green lambda' do | ||
kata_id = '1821E3CB6F' | ||
manifest = make_manifest(kata_id) | ||
manifest['red_amber_green'] = [ | ||
"lambda { |output|", | ||
" return :red if /^Tests run: (\\d*),(\\s)+Failures: (\\d*)/.match(output)", | ||
" return :green if /^OK \\((\\d*) test/.match(output)", | ||
" return :amber", | ||
"}" | ||
] | ||
storer.create_kata(manifest) | ||
kata = katas[kata_id] | ||
assert_equal 'red', ragger.colour(kata, red_output) | ||
end | ||
|
||
private | ||
|
||
def red_output | ||
'Tests run: 1, Failures: 1' | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters