Skip to content

Commit

Permalink
Add web mock extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Darcy Laycock committed Jan 14, 2011
1 parent 1ff97e9 commit 3ee5492
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/api_smith/web_mock_extensions.rb
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

0 comments on commit 3ee5492

Please sign in to comment.