summaryrefslogtreecommitdiff
path: root/test/integration/server_test.rb
blob: 5bc7089d06410e6f25ed35d35db682ea78c154f6 (plain)
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
class ServerTest < Minitest::Test
  include Rack::Test::Methods

  def app
    Server.new
  end

  def test_get_graphql_with_query_string
    header 'Content-Type', 'application/graphql'
    get '/', query: '{me}'

    assert last_response.ok?
    assert_equal 200, last_response.status
    refute_empty last_response.body

    json = JSON.parse(last_response.body)
    assert_equal 'mo', json['data']['me']
  end

  def test_get_graphql_with_post_body
    header 'Content-Type', 'application/graphql'
    post '/', '{me}'

    assert last_response.ok?
    assert_equal 200, last_response.status
    refute_empty last_response.body

    json = JSON.parse(last_response.body)
    assert_equal 'mo', json['data']['me']
  end
end