spec/fakeweb_helper.rb in cloudapp_api-0.2.2 vs spec/fakeweb_helper.rb in cloudapp_api-0.3.0
- old
+ new
@@ -14,12 +14,12 @@
{
# GET URLs
:get => {
%r{http://cl.ly/\w+} => File.join('drop', 'show'),
'http://my.cl.ly/items' => File.join('drop', 'index'),
- 'http://my.cl.ly/items/new' => File.join('drop', 'new-private'),
- 'http://my.cl.ly/items/new?item[private]=true' => File.join('drop', 'new'),
+ 'http://my.cl.ly/items/new' => File.join('drop', 'new'),
+ 'http://my.cl.ly/items/new?item[private]=true' => File.join('drop', 'new-private'),
'http://my.cl.ly/items/s3' => File.join('drop', 'show'),
'http://my.cl.ly/items/s3?item[private]=true' => File.join('drop', 'show-private'),
'http://my.cl.ly/account' => File.join('account', 'show'),
'http://my.cl.ly/account/stats' => File.join('account', 'stats'),
%r{http://my.cl.ly/gift_cards/\w+} => File.join('gift_card', 'show')
@@ -43,6 +43,25 @@
each do |method, requests|
requests.each do |url, response|
FakeWeb.register_uri(method, url, :response => stub_file(response))
end
end
-end
\ No newline at end of file
+end
+
+def fake_it_all_with_errors
+ FakeWeb.clean_registry
+ FakeWeb.register_uri :head, %r{http://(my.|f.)?cl.ly(/items)?}, :status => ["200", "OK"]
+ {
+ :get => {
+ 'http://my.cl.ly/items' => File.join('error', '401'),
+ %r{http://cl.ly/\w+} => File.join('error', '404-find'),
+ 'http://my.cl.ly/items/new' => File.join('drop', 'new')
+ },
+ :put => {
+ %r{http://my.cl.ly/items/\d+} => File.join('error', '404-update')
+ }
+ }.each do |method, requests|
+ requests.each do |url, response|
+ FakeWeb.register_uri(method, url, :response => stub_file(response))
+ end
+ end
+end