Hello,
I'm unable to send any non-text-based body to an active double, and am unsure as to whether this is by design, or due to error on my behalf.
My Gemfile is as follows:
source 'https://rubygems.org' do
gem 'rest-assured'
gem 'rest-client'
gem 'rubocop'
gem 'sqlite3' # for rest-assured
end
Steps are as follows:
Given('a {string} cdn') do |destination|
@full_path = "/#{destination}"
@ra_destination = RestAssured::Double.create(
:fullpath => @full_path,
:verb => 'POST'
)
expect(@ra_destination.status).to eq(200)
end
Note the Then is sending a request to simulate the activity of the accompanying java application:
Then('{string} is received at {string}') do |file, uri|
file = File.read("#{CUCUMBER_DIR}/fixtures/#{chunk_name}")
RestClient.post(
"localhost:4578#{@full_path}#{uri}",
file,
:content_type => 'video/mp4',
)
requests = @ra_destination.reload.requests
expect(requests.first.body).to eq(file)
expect(JSON.parse(requests.first.rack_env)['REQUEST_METHOD']).to eq('POST')
expect(JSON.parse(requests.first.rack_env)['CONTENT_TYPE']).to eq('video/mp4')
expect(JSON.parse(requests.first.rack_env)['REQUEST_URI']).to eq("#{@full_path}#{uri}")
This results in the fourth expect failing, with the top several stack trace line being:
2019-11-18 09:34:57 - Encoding::UndefinedConversionError - "\xC0" from ASCII-8BIT to UTF-8:
/usr/local/lib/ruby/gems/2.6.0/gems/activerecord-5.2.3/lib/active_record/connection_adapters/sqlite3/quoting.rb:56:in `encode'
/usr/local/lib/ruby/gems/2.6.0/gems/activerecord-5.2.3/lib/active_record/connection_adapters/sqlite3/quoting.rb:56:in `_type_cast'
Setting the POST body (and expected requests.body.first to be an arbitrary string causes the test to pass. Note also that this error is also seen when sending a valid curl from the terminal to a live double.
Please advise, thank you.
Hello,
I'm unable to send any non-text-based body to an active double, and am unsure as to whether this is by design, or due to error on my behalf.
My Gemfile is as follows:
Steps are as follows:
Note the
Thenis sending a request to simulate the activity of the accompanying java application:This results in the fourth
expectfailing, with the top several stack trace line being:Setting the
POSTbody (and expectedrequests.body.firstto be an arbitrary string causes the test to pass. Note also that this error is also seen when sending a validcurlfrom the terminal to a live double.Please advise, thank you.