# frozen_string_literal: true

require 'spec_helper'
require 'webmock/rspec'

RSpec.describe Mnemosyne::Probes::Restify::Base do
  it 'creates span' do
    trace = with_trace do
      stub_request(:any, 'google.com')

      require 'restify'
      Restify.new('http://google.com').get.value!
    end

    expect(trace.span.size).to eq 1

    span = trace.span.first

    expect(span.name).to eq 'external.http.restify'
    expect(span.meta[:url]).to eq 'http://google.com'
    expect(span.meta[:method]).to eq :get
  end
end

# frozen_string_literal: true

require 'spec_helper'
require 'webmock/rspec'

RSpec.describe Mnemosyne::Probes::Restify::Base do
  before { require 'restify' }

  describe 'a GET request' do
    subject(:request) { Restify.new('http://google.com').get.value! }

    before do
      stub_request(:get, 'google.com')
        .to_return(status: 200, body: 'search')
    end

    it 'creates a span when tracing' do
      trace = with_trace { request }

      expect(trace.span.size).to eq 1

      span = trace.span.first

      expect(span.name).to eq 'external.http.restify'
      expect(span.meta[:url]).to eq 'http://google.com'
      expect(span.meta[:method]).to eq :get
    end
  end
end

Restructure tests as was done for Faraday
Restructure tests as was done for Faraday
