spec/lita/handlers/tweet_spec.rb in lita-tweet-0.4.1 vs spec/lita/handlers/tweet_spec.rb in lita-tweet-0.4.2
- old
+ new
@@ -28,10 +28,24 @@
before(:each) do
Lita::Authorization.new(registry.config).add_user_to_group!(source.user, :tweeters)
end
+ def expect_tweet(body)
+ stub_request(:post, "https://api.twitter.com/1.1/statuses/update.json").
+ with(body: {status: body}).to_return(status: 200, body: %q[{
+ "created_at": "Sun Aug 14 01:53:54 +0000 2016",
+ "id": 12345,
+ "text": "some text",
+ "user": {
+ "id": 123,
+ "screen_name": "handle",
+ "created_at": "Wed Nov 04 17:18:22 +0000 2009"
+ }
+ }])
+ end
+
describe "#tweet" do
context "without an authorized account" do
it "should complain" do
send_command("tweet some text")
expect(replies).to include(/no accounts/i)
@@ -42,22 +56,18 @@
before do
subject.twitter_data.add_account("token", "secret", "handle")
end
it "should send a tweet" do
- stub_request(:post, "https://api.twitter.com/1.1/statuses/update.json").
- with(body: {status: "some text"}).to_return(status: 200, body: %q[{
- "created_at": "Sun Aug 14 01:53:54 +0000 2016",
- "id": 12345,
- "text": "some text",
- "user": {
- "id": 123,
- "screen_name": "handle",
- "created_at": "Wed Nov 04 17:18:22 +0000 2009"
- }
- }])
+ expect_tweet("some text")
send_command("tweet some text")
- expect(replies).to include("https://twitter.com/handle/status/12345")
+ expect(replies).to include("Tweet posted!")
+ end
+
+ it "should capture newlines" do
+ expect_tweet("para one\n\npara two")
+ send_command("tweet para one\n\npara two")
+ expect(replies).to include("Tweet posted!")
end
end
end
end