Skip to content

Commit 07fd584

Browse files
committed
WIP: Add more tests
1 parent ae8d700 commit 07fd584

7 files changed

Lines changed: 62 additions & 4 deletions

File tree

lib/tweetkit/auth.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module Tweetkit
22
# Module for checking client authentication methods
33
module Auth
4-
private
5-
64
# Determines if requests are to be authenticated with OAuth 1.0a (with consumer and access tokens)
75
#
86
# @return [Boolean]

lib/tweetkit/error.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require "faraday"
22

3+
# TODO: Refactor error handling to be more robust
34
module Tweetkit
45
class Error < StandardError
56
class ClientError < Faraday::ClientError; end

lib/tweetkit/response/tweets.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ class Tweets
1515
# @!method prev_token
1616
# @see Tweetkit::Response::Tweets::Meta#prev_token
1717
# @return [String]
18+
# @!method previous_token
19+
# @see Tweetkit::Response::Tweets::Meta#previous_token
20+
# @return [String]
1821
def_delegators :meta, :next_token, :prev_token, :previous_token
1922

2023
def initialize(response, **options)

test/tweetkit/auth_test.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
require "test_helper"
2+
3+
class Tweetkit::AuthTest < Minitest::Test
4+
def test_token_auth?
5+
client = Tweetkit::Client.new(
6+
access_token: ENV["ACCESS_TOKEN"],
7+
access_token_secret: ENV["ACCESS_TOKEN_SECRET"],
8+
consumer_key: ENV["CONSUMER_KEY"],
9+
consumer_secret: ENV["CONSUMER_SECRET"]
10+
)
11+
12+
assert client.token_auth?
13+
refute client.bearer_auth?
14+
end
15+
16+
def test_bearer_auth?
17+
client = Tweetkit::Client.new(
18+
bearer_token: ENV["BEARER_TOKEN"],
19+
)
20+
21+
refute client.token_auth?
22+
assert client.bearer_auth?
23+
end
24+
end

test/tweetkit/error_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require "test_helper"
2+
3+
# TODO
4+
class Tweetkit::ErrorTest < Minitest::Test
5+
end

test/tweetkit/response/tweet_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
require "test_helper"
22

33
class Tweetkit::Response::TweetTest < Minitest::Test
4-
attr_accessor :client
5-
64
TWEET_ID = 1212092628029698048
75
GEO_TWEET_ID = 1136048014974423040
86
POLL_TWEET_ID = 1199786642791452673
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require "test_helper"
2+
3+
class Tweetkit::Response::TweetsTest < Minitest::Test
4+
TWEET_ID = 1212092628029698048
5+
GEO_TWEET_ID = 1136048014974423040
6+
POLL_TWEET_ID = 1199786642791452673
7+
8+
def setup
9+
@client = Tweetkit::Client.new(bearer_token: ENV["BEARER_TOKEN"])
10+
@tweets = @client.tweets([TWEET_ID, GEO_TWEET_ID, POLL_TWEET_ID], all_public_fields_and_expansions: true)
11+
end
12+
13+
# def test_tweets
14+
# assert_equal Tweetkit::Response::Tweets, @tweets.class
15+
# end
16+
17+
def test_meta
18+
@tweets = @client.search("twitter")
19+
assert_equal Tweetkit::Response::Tweets::Meta, @tweets.meta.class
20+
end
21+
22+
# def test_last
23+
# assert_equal Tweetkit::Response::Tweet, @tweets.last.class
24+
# end
25+
26+
# def test_array_accessor
27+
# assert_equal Tweetkit::Response::Tweet, @tweets[0].class
28+
# end
29+
end

0 commit comments

Comments
 (0)