Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Add SlackSource spec
Browse files Browse the repository at this point in the history
  • Loading branch information
dougedey-shopify committed Aug 30, 2018
1 parent d0ba2ec commit e12070a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
1 change: 0 additions & 1 deletion dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ name: lita-slack
up:
- ruby:
version: 2.4.3
- railgun
2 changes: 1 addition & 1 deletion lib/lita/adapters/slack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def room_roster(room_id, api)

def try_get(object, attribute)
if object.respond_to? attribute
object.attribute
object.send(attribute)
else
nil
end
Expand Down
36 changes: 36 additions & 0 deletions spec/lita/adapters/slack/slack_source_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require "spec_helper"

describe Lita::Adapters::Slack::SlackSource, lita: true do
subject { described_class.new(room: room_source, extensions: extensions) }

let(:room_source) { Lita::Source.new(room: 'C024BE91L') }

describe "with timestamps" do
let(:extensions) do
{
:timestamp => "123456.789",
:thread_ts => "98765.12"
}
end

it "can read timestamp" do
expect(subject.timestamp).to eq("123456.789")
end

it "can read thread_ts" do
expect(subject.thread_ts).to eq("98765.12")
end
end

describe "without extensions" do
let(:extensions) { { } }

it "can read timestamp" do
expect(subject.timestamp).to eq(nil)
end

it "can read thread_ts" do
expect(subject.thread_ts).to eq(nil)
end
end
end

0 comments on commit e12070a

Please sign in to comment.