module Boty module Slack RSpec.describe Users do subject(:users) { described_class.new } let(:action) { :info } let(:url) { "https://slack.com/api/users.#{action}?"+ "token=#{ENV['SLACK_BOT_API_TOKEN']}" } before do allow(Slack::URL).to receive(:get).with(url + "&user=U023BECGF"). and_return( { "ok" => true, "user" => { "id" => "U023BECGF", "name" => "julian" } } ) end describe "#info" do it "calls Slack::URL get with token and user" do expect(Slack::URL).to receive(:get).with(url + "&user=U023BECGF") users.info "U023BECGF" end it "returns a channel object with the im channel information" do expect(Slack::URL).to receive(:get).with(url + "&user=U023BECGF") user = users.info("U023BECGF") expect(user.id).to eq "U023BECGF" expect(user.name).to eq "julian" end end end end end