summaryrefslogtreecommitdiff
path: root/spec/syntax_suggest/fixtures/webmock.rb.txt
blob: 16da0d2ac0701c976e8333a33b41965f0a6f6677 (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
32
33
34
35
describe "webmock tests" do
  before(:each) do
    WebMock.enable!
  end

  after(:each) do
    WebMock.disable!
  end

  it "port" do
    port = rand(1000...9999)
    stub_request(:any, "localhost:#{port}")

    query = Cutlass::FunctionQuery.new(
      port: port
    ).call

    expect(WebMock).to have_requested(:post, "localhost:#{port}").
      with(body: "{}")
  end

  it "body" do
    body = { lol: "hi" }
    port = 8080
    stub_request(:any, "localhost:#{port}")

    query = Cutlass::FunctionQuery.new(
      port: port
      body: body
    ).call

    expect(WebMock).to have_requested(:post, "localhost:#{port}").
      with(body: body.to_json)
  end
end