Vamos criar um arquivo de teste: spec/httparty/httparty_spec.rb
describe 'HTTParty' do
it 'HTTParty' do
response = HTTParty.get('http://jsonplaceholder.typicode.com/posts/2')
content_type = response.headers["content-type"]
expect(content_type).to match(/application\/json/)
end
end
Aqui ele faz uma requisição, recebe uma resposta e verificamos no header se o content-type corresponde a 'aplication/json'.
Instalação no arquivo Gemfile
gem 'httparty'
Vamos criar um arquivo de teste: spec/httparty/httparty_spec.rb
Aqui ele faz uma requisição, recebe uma resposta e verificamos no header se o content-type corresponde a 'aplication/json'.