Permalink
Browse files

Remove Twitter::Client#rate_limit

  • Loading branch information...
1 parent b2ec010 commit 3a4be52a50ad20875b1cf48871f7754944593c95 @sferik committed Sep 10, 2012
Showing with 21 additions and 14 deletions.
  1. +1 −1 README.md
  2. +0 −4 lib/twitter/client.rb
  3. +2 −0 lib/twitter/error.rb
  4. +1 −1 lib/twitter/rate_limit.rb
  5. +0 −8 spec/twitter/client_spec.rb
  6. +17 −0 spec/twitter/rate_limit_spec.rb
View
@@ -273,7 +273,7 @@ Here are some fun facts about the 3.0 release:
* The entire library is implemented in just 2,000 lines of code
* With over 5,000 lines of specs, the spec-to-code ratio is over 2.5:1
-* The spec suite contains 649 examples and runs in under 2 seconds on a MacBook
+* The spec suite contains 648 examples and runs in under 2 seconds on a MacBook
* This project has 100% C0 code coverage (the tests execute every line of
source code at least once)
* At the time of release, this library is comprehensive: you can request all
View
@@ -4,7 +4,6 @@
require 'twitter/configurable'
require 'twitter/error/client_error'
require 'twitter/error/decode_error'
-require 'twitter/rate_limit'
require 'simple_oauth'
require 'uri'
@@ -16,7 +15,6 @@ module Twitter
class Client
include Twitter::API
include Twitter::Configurable
- attr_reader :rate_limit
# Initializes a new Client object
#
@@ -26,7 +24,6 @@ def initialize(options={})
Twitter::Configurable.keys.each do |key|
instance_variable_set(:"@#{key}", options[key] || Twitter.instance_variable_get(:"@#{key}"))
end
- @rate_limit = Twitter::RateLimit.new
end
# Perform an HTTP DELETE request
@@ -82,7 +79,6 @@ def request(method, path, params={}, options={})
end
yield request if block_given?
end.env
- @rate_limit.update(response[:response_headers])
response
rescue Faraday::Error::ClientError
raise Twitter::Error::ClientError
View
@@ -1,3 +1,5 @@
+require 'twitter/rate_limit'
+
module Twitter
# Custom error class for rescuing from all Twitter errors
class Error < StandardError
@@ -32,7 +32,7 @@ def reset_in
end
alias retry_after reset_in
- # Update the attributes of a Relationship
+ # Update the attributes of a RateLimit
#
# @param attrs [Hash]
# @return [Twitter::RateLimit]
@@ -82,14 +82,6 @@
client2.verify_credentials.id.should eq 14100886
end
- describe "#initalize" do
- it "returns a different rate limit object for a new client" do
- client1 = Twitter::Client.new
- client2 = Twitter::Client.new
- client1.rate_limit.should_not eq client2.rate_limit
- end
- end
-
describe "#delete" do
before do
stub_delete("/custom/delete").
@@ -56,4 +56,21 @@
end
end
+ describe "#update" do
+ before do
+ Timecop.freeze(Time.utc(2012, 6, 6, 17, 22, 0))
+ end
+ after do
+ Timecop.return
+ end
+ it "updates a rate limit" do
+ rate_limit = Twitter::RateLimit.new('x-rate-limit-reset' => "1339019097")
+ rate_limit.reset_in.should be_an Integer
+ rate_limit.reset_in.should eq 15777
+ rate_limit.update({'x-rate-limit-reset' => "1339019098"})
+ rate_limit.reset_in.should be_an Integer
+ rate_limit.reset_in.should eq 15778
+ end
+ end
+
end

0 comments on commit 3a4be52

Please sign in to comment.