Commit 58acc2b6 authored by Ash McKenzie's avatar Ash McKenzie

Make ordered expectations around results output

This also cleans up the output from the tests as previously, Base64 encoded output was printed.
parent 708e60c2
......@@ -90,8 +90,8 @@ module Action
def print_flush(str)
return false unless str
print(Base64.decode64(str))
STDOUT.flush
$stdout.print(Base64.decode64(str))
$stdout.flush
end
def validate!
......
......@@ -38,9 +38,24 @@ describe Action::Custom do
end
context 'and responds correctly' do
it 'returns an instance of Net::HTTPCreated' do
it 'prints a Base64 encoded result to $stdout' do
VCR.use_cassette("custom-action-ok") do
expect(subject.execute).to be_instance_of(Net::HTTPCreated)
expect($stdout).to receive(:print).with('info_refs-result').ordered
expect($stdout).to receive(:print).with('push-result').ordered
subject.execute
end
end
context 'with results printed to $stdout' do
before do
allow($stdout).to receive(:print).with('info_refs-result')
allow($stdout).to receive(:print).with('push-result')
end
it 'returns an instance of Net::HTTPCreated' do
VCR.use_cassette("custom-action-ok") do
expect(subject.execute ).to be_instance_of(Net::HTTPCreated)
end
end
end
end
......
......@@ -46,7 +46,7 @@ http_interactions:
- '1.436040'
body:
encoding: UTF-8
string: '{"result":"info_refs-result"}'
string: '{"result":"aW5mb19yZWZzLXJlc3VsdA==\n"}'
http_version:
recorded_at: Fri, 20 Jul 2018 06:18:58 GMT
- request:
......@@ -93,7 +93,7 @@ http_interactions:
- '0.786754'
body:
encoding: UTF-8
string: '{"result":"push-result"}'
string: '{"result":"cHVzaC1yZXN1bHQ=\n"}'
http_version:
recorded_at: Fri, 20 Jul 2018 06:19:08 GMT
recorded_with: VCR 2.4.0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment