require "spec_helper" module Boty module Slack RSpec.describe IM do subject(:im) { described_class.new } let(:action) { :open } let(:im_url) { "https://slack.com/api/im.#{action}?" \ "token=#{ENV['SLACK_BOT_API_TOKEN']}" } describe "#open" do it "calls Slack::URL get with token and user" do expect(Slack::URL).to receive(:get).with(im_url + "&user=U1234") im.open "U1234" end it "returns a channel object with the im channel information" do expect(Slack::URL).to receive(:get).with(im_url + "&user=U1234") .and_return( "ok" => true, "channel" => { "id" => "D024BFF1M" } ) expect(im.open("U1234").id).to eq "D024BFF1M" end end end end end