Skip to content

Commit

Permalink
Add user_agent methods to Base class
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Sep 24, 2010
1 parent 584bcf9 commit 0fc68f1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/twitter.rb
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions test/twitter_test.rb
@@ -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
Expand Down

0 comments on commit 0fc68f1

Please sign in to comment.