vanderleipinto / test_app

0 stars 0 forks source link

feat: httparty #38

Closed vanderleipinto closed 7 months ago

vanderleipinto commented 7 months ago

Instalação no arquivo Gemfile

gem 'httparty'

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'.