2019-12-04 20:38:33 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Mattermost::Client do
|
2017-08-17 22:00:37 +05:30
|
|
|
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)
|
2021-09-04 01:27:46 +05:30
|
|
|
expect { subject.send(:json_response, bad_json) }.to raise_error(::Mattermost::ClientError)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows a client error if the request was unsuccessful' do
|
|
|
|
bad_request = Struct::Request.new("true", false)
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
expect { subject.send(:json_response, bad_request) }.to raise_error(::Mattermost::ClientError)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|