spec/integration/client_spec.rb in peertransfer_chat-0.0.1 vs spec/integration/client_spec.rb in peertransfer_chat-0.1.0
- old
+ new
@@ -1,35 +1,60 @@
require 'spec_helper'
describe PeertransferChat::Client do
- let(:slack_client) { instance_double(Slackr) }
+ let(:slack_client) { instance_spy(Slackr) }
let(:team_name) { 'a team' }
let(:team_token) { 'a token' }
let(:team_channel) { 'a channel' }
let(:team_username) { 'a username' }
let(:opts) { { 'channel' => team_channel, 'username' => team_username } }
- after do
- PeertransferChat.reset!
- end
+ context 'with class configuration' do
+ before do
+ PeertransferChat.configure do |c|
+ c.team = team_name
+ c.incoming_token = team_token
+ c.channel = team_channel
+ c.username = team_username
+ end
- before do
- PeertransferChat.configure do |c|
- c.team = team_name
- c.incoming_token = team_token
- c.channel = team_channel
- c.username = team_username
+ allow(Slackr).to receive(:connect).
+ with(team_name, team_token, opts).
+ and_return(slack_client)
end
- allow(Slackr).to receive(:connect).
- with(team_name, team_token, opts).
- and_return(slack_client)
+ describe '.say' do
+ it 'speaks something to a channel' do
+ described_class.speak('hello')
+
+ expect(slack_client).to have_received(:say).with('hello')
+
+ PeertransferChat.reset!
+ end
+ end
end
- describe '.say' do
- it 'speaks something to a channel' do
- expect(slack_client).to receive(:say).with('hello')
+ context 'with instance configuration' do
+ before do
+ allow(Slackr).to receive(:connect).
+ with(team_name, team_token, opts).
+ and_return(slack_client)
+ end
- described_class.speak('hello')
+ let(:client) do
+ PeertransferChat::Client.new do |c|
+ c.team = team_name
+ c.incoming_token = team_token
+ c.channel = team_channel
+ c.username = team_username
+ end
+ end
+
+ describe '.say' do
+ it 'speaks something to a channel' do
+ client.speak('hello')
+
+ expect(slack_client).to have_received(:say).with('hello')
+ end
end
end
end