2019-08-22 10:57:44 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-21 12:34:24 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 18:09:03 +00:00
|
|
|
RSpec.describe Mattermost::Client do
|
2016-12-21 12:34:24 +00:00
|
|
|
let(:user) { build(:user) }
|
|
|
|
|
|
|
|
subject { described_class.new(user) }
|
|
|
|
|
|
|
|
context 'JSON parse error' do
|
|
|
|
before do
|
|
|
|
Struct.new("Request", :body, :success?)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'yields an error on malformed JSON' do
|
|
|
|
bad_json = Struct::Request.new("I'm not json", true)
|
|
|
|
expect { subject.send(:json_response, bad_json) }.to raise_error(Mattermost::ClientError)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows a client error if the request was unsuccessful' do
|
|
|
|
bad_request = Struct::Request.new("true", false)
|
|
|
|
|
|
|
|
expect { subject.send(:json_response, bad_request) }.to raise_error(Mattermost::ClientError)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|