test/fake_server.rb in roar-0.10.0 vs test/fake_server.rb in roar-0.10.1
- old
+ new
@@ -1,43 +1,62 @@
require "bundler/setup"
require 'sinatra/base'
-
-class FakeServer < Sinatra::Base
- get "/method" do
- "<method>get</method>"
+
+class FakeServer < Sinatra::Base
+
+ set :raise_errors, false
+
+ get "/method" do
+ "<method>get</method>"
end
-
- post "/method" do
- "<method>post</method>"
+
+ post "/method" do
+ "<method>post</method>"
end
- put "/method" do
- "<method>put</method>"
+ put "/method" do
+ "<method>put</method>"
end
- delete "/method" do
- "<method>delete</method>"
+ delete "/method" do
+ "<method>delete</method>"
end
- #patch "/method" do
- # "<method>patch</method>"
- #end
-
+ patch "/method" do
+ "<method>patch</method>"
+ end
+
+ get '/deliberate-error' do
+ raise 'this error was deliberate'
+ end
+
post "/bands" do
#if request.content_type =~ /xml/
- '{"label": "n/a", "name": "Strung Out", "links": [{"href":"http://search", "rel": "search"}, {"href":"http://band/strungout", "rel": "self"}]}'
+ body '{"label": "n/a", "name": "Strung Out", "links": [{"href":"http://search", "rel": "search"}, {"href":"http://band/strungout", "rel": "self"}]}'
+ status 201
end
put "/bands/strungout" do
+ # DISCUSS: as long as we don't agree on what to return in PUT/PATCH, let's return an updated document.
{:name => "Strung Out", :label => "Fat Wreck"}.to_json
+ #status 204
end
-
+
+ patch '/bands/strungout' do
+ # DISCUSS: as long as we don't agree on what to return in PUT/PATCH, let's return an updated document.
+ {:name => 'Strung Out', :label => 'Fat Mike'}.to_json
+ #status 204
+ end
+
get "/bands/slayer" do
{:name => "Slayer", :label => "Canadian Maple"}.to_json
end
-
-
+
+ delete '/banks/metallica' do
+ status 204
+ end
+
require './test/order_representers'
JSON::Order.class_eval do
def items_url
"http://roar.example.com/orders/1/items"
end
@@ -67,8 +86,8 @@
end
get "/orders/1" do
JSON::Order.new(:client_id => 1, :items => [JSON::Item.new(:article_id => "666-S", :amount => 1)]).serialize
end
-
-end
-
+
+end
+