File: http_test.rb

package info (click to toggle)
ruby-hangouts-chat 0.0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 124 kB
  • sloc: ruby: 132; makefile: 3
file content (31 lines) | stat: -rw-r--r-- 791 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'test_helper'

class HTTPTest < Minitest::Test
  def setup
    @url = 'https://example.com'
    @http = HangoutsChat::Sender::HTTP.new(@url)
  end

  def test_initialized_with_valid_uri
    uri = @http.instance_variable_get(:@uri)
    assert_equal 'https', uri.scheme
    assert_equal 'example.com', uri.host
  end

  def test_initialized_with_valid_post_request
    req = @http.instance_variable_get(:@req)
    assert_equal 'POST', req.method
    assert_equal 'application/json', req['Content-Type']
  end

  def xtest_post_request
    stub_request(:any, @url)
    payload = 'Test text'

    @http.post(payload)

    assert_requested :post, @url, times: 1, body: payload.to_json, headers:
      { 'Content-Type' => 'application/json' }
    assert_not_requested :get, @url
  end
end