forked from Sutto/api_smith
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Darcy Laycock
committed
Jan 14, 2011
1 parent
1ff97e9
commit 3ee5492
Showing
1 changed file
with
23 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module APISmith | ||
module WebMockExtensions | ||
|
||
def subject_api_class | ||
subject.is_a?(Class) ? subject : subject.class | ||
end | ||
|
||
def subject_class_instance | ||
@subject_class_instance ||= subject_api_class.allocate | ||
end | ||
|
||
def api_url_for(path) | ||
path = subject_class_instance.send(:path_for, path) | ||
base_uri = subject_api_class.base_uri | ||
File.join base_uri, path | ||
end | ||
|
||
def stub_api(type, path) | ||
stub_request(type, api_url_for(path)) | ||
end | ||
|
||
end | ||
end |