spec/boty/slack/users_spec.rb in boty-0.1.0 vs spec/boty/slack/users_spec.rb in boty-0.1.1
- old
+ new
@@ -1,52 +1,52 @@
module Boty
module Slack
RSpec.describe Users do
def url_for(action)
- "https://slack.com/api/users.#{action}?"+
+ "https://slack.com/api/users.#{action}?" \
"token=#{ENV['SLACK_BOT_API_TOKEN']}"
end
subject(:users) { described_class.new }
before do
- allow(Slack::URL).to receive(:get).with(url_for(:info) + "&user=U123456").
- and_return(
+ allow(Slack::URL).to receive(:get)
+ .with(url_for(:info) + "&user=U123456").and_return(
"ok" => true,
"user" => {
"id" => "U123456",
"name" => "julian"
}
- )
+ )
- allow(Slack::URL).to receive(:get).with(url_for(:list)).
- and_return(
- {
- "ok" => true,
- "members" => [
- {
- "id" => "U023BECGF",
- "name" => "bobby"
- },
- {
- "id" => "U123456",
- "name" => "julian"
- }
- ]
- }
- )
+ allow(Slack::URL).to receive(:get).with(url_for(:list))
+ .and_return(
+ "ok" => true,
+ "members" => [
+ {
+ "id" => "U023BECGF",
+ "name" => "bobby"
+ },
+ {
+ "id" => "U123456",
+ "name" => "julian"
+ }
+ ]
+ )
end
describe "#info" do
it "calls Slack::URL get with token and user" do
- expect(Slack::URL).to receive(:get).with(url_for(:info) + "&user=U123456")
+ expect(Slack::URL).to receive(:get)
+ .with(url_for(:info) + "&user=U123456")
users.info "U123456"
end
it "returns a channel object with the im channel information" do
- expect(Slack::URL).to receive(:get).with(url_for(:info) + "&user=U123456")
+ expect(Slack::URL).to receive(:get)
+ .with(url_for(:info) + "&user=U123456")
user = users.info("U123456")
expect(user.id).to eq "U123456"
expect(user.name).to eq "julian"
@@ -54,10 +54,10 @@
end
describe "#list" do
it "retrieves the users list" do
list = Slack.users.list
- expect(list.map(&:name)).to eq ["bobby", "julian"]
+ expect(list.map(&:name)).to eq %w(bobby julian)
end
end
describe "#by_name" do
it "uses the users.list to discover info on a given user.name" do