Skip to content

Commit

Permalink
refactoring; deleted unused argument in StubRunner.stub_run_output, d…
Browse files Browse the repository at this point in the history
…eleted unneeded use of MockProxyHostShell from StubRunnerTest
  • Loading branch information
JonJagger committed Dec 27, 2016
1 parent f55701d commit 7242aa4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion app/lib/stub_runner.rb
Expand Up @@ -26,7 +26,7 @@ def old_avatar(_kata_id, _avatar_name); end

# - - - - - - - - - - - - - - - - -

def stub_run_output(_avatar, output)
def stub_run_output(output)
save_stub(output)
end

Expand Down
2 changes: 1 addition & 1 deletion test/app_lib/delta_maker.rb
Expand Up @@ -44,7 +44,7 @@ def stub_colour(colour)
all_outputs = Dir.glob(path + '/*')
filename = all_outputs.sample
output = File.read(filename)
nearest_ancestors(:runner, @avatar).stub_run_output(@avatar, output)
nearest_ancestors(:runner, @avatar).stub_run_output(output)
@stubbed = true
end

Expand Down
44 changes: 23 additions & 21 deletions test/app_lib/stub_runner_test.rb
Expand Up @@ -2,18 +2,6 @@

class StubRunnerTest < AppLibTestBase

def setup
super
set_shell_class 'MockProxyHostShell'
end

def teardown
shell.teardown
super
end

# - - - - - - - - - - - - - - - - - - - - - - - - - - - -

test '43E866',
'pulled? is true only for 4 specific images' do
assert runner.pulled? cdf('nasm_assert')
Expand All @@ -36,26 +24,40 @@ def teardown
'stub_run_output stubs output for subsequent run' do
kata = make_kata
lion = kata.start_avatar(['lion'])
runner.stub_run_output(lion, output='syntax error line 1')
stdout,stderr,status = runner.run(kata.image_name, kata.id, 'lion', _delta=nil, _files=nil, _image_name=nil)
runner.stub_run_output(output='syntax error line 1')
stdout,_stderr,_status = runner.run(*unused_args)
assert_equal output, stdout
end

# - - - - - - - - - - - - - - - - - - - - - - - - - - - -

test 'AF797E',
'run without preceeding stub returns amber' do
'run without preceeding stub returns blah blah' do
kata = make_kata
lion = kata.start_avatar(['lion'])
stdout,stderr,status = runner.run(kata.image_name, kata.id, 'lion', _delta=nil, _files=nil, _image_name=nil)
output = stdout + stderr
colour = ragger.colour(kata, output)
assert_equal 'amber', colour
stdout,_stderr,_status = runner.run(*unused_args)
assert stdout.start_with? 'blah'
end

# - - - - - - - - - - - - - - - - - - - - - - - - - - - -

def cdf(image); 'cyberdojofoundation/'+image; end
def success; 0; end
def cdf(image)
'cyberdojofoundation/' + image
end

def success
0
end

def unused_args
args = []
args << (image_name = nil)
args << (kata_id = nil)
args << (avatar_name = nil)
args << (deleted_filenames = nil)
args << (changed_files = nil)
args << (max_seconds = nil)
args
end

end
2 changes: 1 addition & 1 deletion test/app_models/avatar_test.rb
Expand Up @@ -69,7 +69,7 @@ def setup
visible_files = @avatar.visible_files
assert visible_files.keys.include?('output')
assert_equal '', visible_files['output']
runner.stub_run_output(@avatar, expected = 'helloWorld')
runner.stub_run_output(expected = 'helloWorld')
_, @visible_files, @output = DeltaMaker.new(@avatar).run_test
assert @visible_files.keys.include?('output')
end
Expand Down

0 comments on commit 7242aa4

Please sign in to comment.