From 4a03fae930a58b485ee610ce9e6058a2c2dd3d6e Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Tue, 20 Dec 2016 20:56:46 +0100 Subject: Fix rspec tests due to different API [ci skip] --- spec/lib/mattermost/command_spec.rb | 15 ++++++++++----- spec/lib/mattermost/team_spec.rb | 17 +++++------------ 2 files changed, 15 insertions(+), 17 deletions(-) (limited to 'spec/lib/mattermost') diff --git a/spec/lib/mattermost/command_spec.rb b/spec/lib/mattermost/command_spec.rb index ecf336e3199..f70aee7f3e5 100644 --- a/spec/lib/mattermost/command_spec.rb +++ b/spec/lib/mattermost/command_spec.rb @@ -1,17 +1,22 @@ require 'spec_helper' describe Mattermost::Command do - let(:hash) { { 'token' => 'token' } } - let(:user) { create(:user) } + let(:params) { { 'token' => 'token', team_id: 'abc' } } + let(:user) { build(:user) } before do Mattermost::Session.base_uri("http://mattermost.example.com") end + subject { described_class.new(user) } + describe '#create' do - it 'creates a command' do - described_class.new(user). - create(team_id: 'abc', url: 'http://trigger.com') + it 'interpolates the team id' do + allow(subject).to receive(:json_post). + with('/api/v3/teams/abc/commands/create', body: params.to_json). + and_return('token' => 'token') + + subject.create(params) end end end diff --git a/spec/lib/mattermost/team_spec.rb b/spec/lib/mattermost/team_spec.rb index 5d1fc6fc603..ef39c456d5f 100644 --- a/spec/lib/mattermost/team_spec.rb +++ b/spec/lib/mattermost/team_spec.rb @@ -2,7 +2,9 @@ require 'spec_helper' describe Mattermost::Team do describe '#all' do - let(:session) { double("session") } + let(:user) { build(:user) } + + subject { described_class.new(user) } let(:response) do [{ @@ -20,22 +22,13 @@ describe Mattermost::Team do "allow_open_invite" => false }] end - let(:json) { nil } before do - allow(session).to receive(:get).with('/api/v3/teams/all'). - and_return(json) - allow(json).to receive(:parsed_response).and_return(response) + allow(subject).to receive(:json_get).and_return(response) end it 'gets the teams' do - expect(described_class.all(session).count).to be(1) - end - - it 'filters on being team admin' do - ids = described_class.all(session).map { |team| team['id'] } - - expect(ids).to include("xiyro8huptfhdndadpz8r3wnbo") + expect(subject.all.count).to be(1) end end end -- cgit v1.2.1