Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add user_agent methods to Base class

  • Loading branch information...
commit 0fc68f1c52e3b754194fe8a9cfbd9d4499eacbe1 1 parent 584bcf9
Erik Michaels-Ober authored
Showing with 20 additions and 0 deletions.
  1. +8 −0 lib/twitter.rb
  2. +12 −0 test/twitter_test.rb
8 lib/twitter.rb
View
@@ -24,6 +24,14 @@ class Unavailable < StandardError; end
class InformTwitter < StandardError; end
class NotFound < StandardError; end
+ def self.user_agent
+ @user_agent ||= 'Ruby Twitter Gem'
+ end
+
+ def self.user_agent=(value)
+ @user_agent = value
+ end
+
def self.api_endpoint
@api_endpoint ||= "api.twitter.com/#{self.api_version}"
end
12 test/twitter_test.rb
View
@@ -1,6 +1,18 @@
require 'test_helper'
class TwitterTest < Test::Unit::TestCase
+
+ should "default User Agent to 'Ruby Twitter Gem'" do
+ assert_equal 'Ruby Twitter Gem', Twitter.user_agent
+ end
+
+ context 'when overriding the user agent' do
+ should "be able to specify the User Agent" do
+ Twitter.user_agent = 'My Twitter Gem'
+ assert_equal 'My Twitter Gem', Twitter.user_agent
+ end
+ end
+
should "have firehose method for public timeline" do
stub_get('http://api.twitter.com/1/statuses/public_timeline.json', 'firehose.json')
hose = Twitter.firehose
Please sign in to comment.
Something went wrong with that request. Please try again.