Commit a71b0626 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Extract stub_sentry_request method

Extract stub_sentry_request into a SentryClientHelpers
parent 8b79e803
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
require 'spec_helper' require 'spec_helper'
describe Sentry::Client::Projects do describe Sentry::Client::Projects do
include SentryClientHelpers
let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' } let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
let(:token) { 'test-token' } let(:token) { 'test-token' }
let(:client) { Sentry::Client.new(sentry_url, token) } let(:client) { Sentry::Client.new(sentry_url, token) }
...@@ -114,15 +116,4 @@ describe Sentry::Client::Projects do ...@@ -114,15 +116,4 @@ describe Sentry::Client::Projects do
it_behaves_like 'maps Sentry exceptions' it_behaves_like 'maps Sentry exceptions'
end end
end end
private
def stub_sentry_request(url, body: {}, status: 200, headers: {})
stub_request(:get, url)
.to_return(
status: status,
headers: { 'Content-Type' => 'application/json' }.merge(headers),
body: body.to_json
)
end
end end
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
require 'spec_helper' require 'spec_helper'
describe Sentry::Client do describe Sentry::Client do
include SentryClientHelpers
let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' } let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
let(:token) { 'test-token' } let(:token) { 'test-token' }
let(:default_httparty_options) do let(:default_httparty_options) do
...@@ -216,15 +218,4 @@ describe Sentry::Client do ...@@ -216,15 +218,4 @@ describe Sentry::Client do
it_behaves_like 'issues has correct length', 1 it_behaves_like 'issues has correct length', 1
end end
end end
private
def stub_sentry_request(url, body: {}, status: 200, headers: {})
stub_request(:get, url)
.to_return(
status: status,
headers: { 'Content-Type' => 'application/json' }.merge(headers),
body: body.to_json
)
end
end end
# frozen_string_literal: true
module SentryClientHelpers
private
def stub_sentry_request(url, body: {}, status: 200, headers: {})
stub_request(:get, url)
.to_return(
status: status,
headers: { 'Content-Type' => 'application/json' }.merge(headers),
body: body.to_json
)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment