Sha256: 9767a2e09c30397d81011e0731d0824a237dd6df6a8217398c26e3bc0a9d7944

Contents?: true

Size: 836 Bytes

Versions: 5

Compression:

Stored size: 836 Bytes

Contents

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
boty-1.0.1 spec/boty/slack/im_spec.rb
boty-1.0.0 spec/boty/slack/im_spec.rb
boty-0.2.0 spec/boty/slack/im_spec.rb
boty-0.1.2 spec/boty/slack/im_spec.rb
boty-0.1.1 spec/boty/slack/im_spec.rb