diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-12-21 15:34:24 +0300 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-12-21 16:11:00 +0300 |
commit | 1ac06396778dec216cf0467a50c67040690656ca (patch) | |
tree | 5eec9ef1796de30c374f5489cccfd83b3f261bb3 /spec/lib/mattermost/client_spec.rb | |
parent | 55c61d2e412733b0feefcb5fa33a96e584ffe2bc (diff) |
Add new tests
Diffstat (limited to 'spec/lib/mattermost/client_spec.rb')
-rw-r--r-- | spec/lib/mattermost/client_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/lib/mattermost/client_spec.rb b/spec/lib/mattermost/client_spec.rb new file mode 100644 index 00000000000..dc11a414717 --- /dev/null +++ b/spec/lib/mattermost/client_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' + +describe Mattermost::Client do + 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 |