|
14 | 14 | end |
15 | 15 | end |
16 | 16 |
|
17 | | -describe Webmachine::Adapters::RackMapped do |
18 | | - it_should_behave_like :adapter_lint do |
19 | | - it "should set Server header" do |
20 | | - response = client.request(Net::HTTP::Get.new("/test")) |
21 | | - expect(response["Server"]).to match(/Webmachine/) |
22 | | - expect(response["Server"]).to match(/Rack/) |
23 | | - end |
24 | | - end |
25 | | -end |
26 | | - |
27 | 17 | describe Webmachine::Adapters::Rack::RackResponse do |
28 | 18 | context "on Rack < 1.5 release" do |
29 | 19 | before { allow(Rack).to receive_messages(:release => "1.4") } |
|
65 | 55 | end |
66 | 56 | end |
67 | 57 | end |
68 | | - |
69 | | -describe Webmachine::Adapters::RackMapped do |
70 | | - class CreateResource < Webmachine::Resource |
71 | | - def allowed_methods |
72 | | - ["POST"] |
73 | | - end |
74 | | - |
75 | | - def content_types_accepted |
76 | | - [["application/json", :from_json]] |
77 | | - end |
78 | | - |
79 | | - def content_types_provided |
80 | | - [["application/json", :to_json]] |
81 | | - end |
82 | | - |
83 | | - def post_is_create? |
84 | | - true |
85 | | - end |
86 | | - |
87 | | - def create_path |
88 | | - "created_path_here/123" |
89 | | - end |
90 | | - |
91 | | - def from_json |
92 | | - response.body = %{ {"foo": "bar"} } |
93 | | - end |
94 | | - end |
95 | | - |
96 | | - let(:app) do |
97 | | - Rack::Builder.new do |
98 | | - map '/some/route' do |
99 | | - run(Webmachine::Application.new do |app| |
100 | | - app.add_route(["test"], Test::Resource) |
101 | | - app.add_route(["create_test"], CreateResource) |
102 | | - app.configure do | config | |
103 | | - config.adapter = :RackMapped |
104 | | - end |
105 | | - end.adapter) |
106 | | - end |
107 | | - end |
108 | | - end |
109 | | - |
110 | | - context "using Rack::Test" do |
111 | | - include Rack::Test::Methods |
112 | | - |
113 | | - it "provides the full request URI" do |
114 | | - rack_response = get "some/route/test", nil, {"HTTP_ACCEPT" => "test/response.request_uri"} |
115 | | - expect(rack_response.body).to eq "http://example.org/some/route/test" |
116 | | - end |
117 | | - |
118 | | - it "provides LOCATION header using custom base_uri when creating from POST request" do |
119 | | - rack_response = post "/some/route/create_test", %{{"foo": "bar"}}, {"HTTP_ACCEPT" => "application/json", "CONTENT_TYPE" => "application/json"} |
120 | | - expect(rack_response.headers["Location"]).to eq("http://example.org/some/route/created_path_here/123") |
121 | | - end |
122 | | - end |
123 | | -end |
0 commit comments