Skip to content

Commit

Permalink
v1.1.2 - Fix small bug with multiline tweets, add coverage for same.
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaberer committed Aug 20, 2014
1 parent 1684924 commit 343b88e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/cinch/plugins/twitterstatus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def format_tweet(url)

def tweet_text(user, status)
# Scrub the tweet for returns so we don't have multilined responses.
status.gsub!(/[\n]+/, ' ') if status.match(/\n/)
status = status.gsub(/[\n]+/, ' ') if status.match(/\n/)
"@#{user} tweeted \"#{status}\""
end

Expand Down
2 changes: 1 addition & 1 deletion lib/cinch/plugins/twitterstatus/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Cinch
module Plugins
# Versioning info
class TwitterStatus
VERSION = '1.1.1'
VERSION = '1.1.2'
end
end
end
18 changes: 8 additions & 10 deletions spec/cinch-twitterstatus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
@status =
{ normal: 'https://twitter.com/weirdo513/status/344186643609174016',
protected: 'https://twitter.com/brewtopian/status/68071618055901184',
invalid: 'https://twitter.com/weirdo513/status/3INVALI643609174016' }
invalid: 'https://twitter.com/weirdo513/status/3INVALI643609174016',
multiline: 'https://twitter.com/Peeardee/status/502209346038951937'}
end

describe "Twitter Link Parsing" do
Expand All @@ -25,6 +26,12 @@
expect(msg.text).to eq('@weirdo513 tweeted "HOW IS THAT MIC STILL ON JESUS"')
end

it 'should return the text of the tweet when linked in the channel' do
msg = get_replies(make_message(@bot, @status[:multiline],
{ channel: '#foo', nick: 'bar' })).first
expect(msg.text).to eq('@Peeardee tweeted "Dear My RP Group, I *will* be working on the Enforcer schedule during our Call of Cthulhu session tonight. Will make frequent sanity rolls."')
end

it 'should not return any text if the status is invalid' do
msg = get_replies(make_message(@bot, @status[:invalid],
{ channel: '#foo', nick: 'bar' }))
Expand All @@ -44,13 +51,4 @@
expect(msg).to be_empty
end
end

describe "Watchers" do
# FIXME: cinch-test does not allow timers to function
it 'should not post tweets that already existed when the bot was started' do
sleep 20
get_replies(make_message(@bot, @status[:normal],
{ channel: '#foo', nick: 'bar' }))
end
end
end

0 comments on commit 343b88e

Please sign in to comment.