-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Massive refactoring to the internals to simplify
* Move per call configuration out to API/Cache classes thereby reducing knowledge of their internals by APICache class * Simpler mocked specs for APICache * Proper specs for the API and Cache classes
- Loading branch information
Showing
6 changed files
with
190 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,44 @@ | ||
require File.dirname(__FILE__) + '/spec_helper' | ||
|
||
describe APICache::API do | ||
it "should handle redirecting get requests" do | ||
api = APICache::API.new | ||
lambda { | ||
api.get('http://froogle.google.com', 5) | ||
}.should_not raise_error(APICache::CannotFetch) | ||
before :each do | ||
@options = { | ||
:period => 1, | ||
:timeout => 5 | ||
} | ||
end | ||
end | ||
|
||
it "should not be queryable? for :period seconds after a request" do | ||
api = APICache::API.new('http://www.google.com/', @options) | ||
api.should be_queryable | ||
api.get | ||
api.should_not be_queryable | ||
sleep 1 | ||
api.should be_queryable | ||
end | ||
|
||
describe "without a block - key is the url" do | ||
|
||
it "should return body of a http GET against the key" do | ||
api = APICache::API.new('http://www.google.com/', @options) | ||
api.get.should =~ /Google/ | ||
end | ||
|
||
it "should handle redirecting get requests" do | ||
api = APICache::API.new('http://froogle.google.com/', @options) | ||
api.get.should =~ /Google Product Search/ | ||
end | ||
|
||
end | ||
|
||
describe "with a block" do | ||
|
||
it "should return the return value of the block" do | ||
api = APICache::API.new('http://froogle.google.com/', @options) do | ||
42 | ||
end | ||
api.get.should == 42 | ||
end | ||
|
||
end | ||
end |
Oops, something went wrong.