Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Verify mode is a valid option.
  • Loading branch information
Christi Viets committed May 19, 2017
1 parent a39ec9c commit a91a99d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mountebank/stub/http_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def self.create(statusCode=200, headers={}, body='', behaviors={}, mode='')
payload[:statusCode] = statusCode
payload[:headers] = headers unless headers.empty?
payload[:body] = body unless body.empty?
payload[:_mode] = mode unless mode.empty?
payload[:_mode] = mode if (mode == 'text' or mode == 'binary')

data = {is: payload}
data.merge!(_behaviors: behaviors) unless behaviors.empty?
Expand Down
8 changes: 8 additions & 0 deletions spec/mountebank/stub/http_response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
end
end

context 'invalid binary mode' do
let(:mode) { 'random' }
it 'returns response object without binary mode' do
expect(response).to be_a Mountebank::Stub::HttpResponse
expect(response.to_json).to eq '{"is":{"statusCode":200,"headers":{"Content-Type":"application/json"},"body":"{\"foo\":\"bar\"}"}}'
end
end

context 'with behaviors' do
let(:behaviors) { { wait: 10000 } }
it 'returns a response object' do
Expand Down

0 comments on commit a91a99d

Please sign in to comment.