Sha256: 02f83ffcf2898267959ecdc3c2af24f8952ec7da2113501bfbffa7bd2de3a87b
Contents?: true
Size: 1.82 KB
Versions: 2
Compression:
Stored size: 1.82 KB
Contents
require "spec_helper" describe Lita::Handlers::Tweet, lita_handler: true do # Chat routes { "tweet some text" => :tweet, "untweet" => :untweet, "twitter accounts" => :accounts, "twitter accounts add" => :accounts, "twitter accounts remove foo" => :accounts, "twitter default foo" => :default, "twitter map" => :map, "twitter map foo" => :map, "twitter unmap foo" => :unmap }.each do |command, method| it { is_expected.to route_command(command). with_authorization_for(:tweeters). to(method) } end # HTTP routes { "/twitter/auth" => :twitter_auth, "/twitter/callback" => :twitter_auth_callback }.each do |route, method| it { is_expected.to route_http(:get, route).to(method) } end before(:each) do Lita::Authorization.new(registry.config).add_user_to_group!(source.user, :tweeters) 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) end end context "with an authorized account" do 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" } }]) send_command("tweet some text") expect(replies).to include("https://twitter.com/handle/status/12345") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lita-tweet-0.4.1 | spec/lita/handlers/tweet_spec.rb |
lita-tweet-0.4.0 | spec/lita/handlers/tweet_spec.rb |