Class: Test::Resource
Instance Attribute Summary
#request, #response
Instance Method Summary
collapse
new, run
#trace?
#weak_etag
#encode_deflate, #encode_gzip, #encode_identity
#allow_missing_post?, #base_uri, #charsets_provided, #create_path, #delete_completed?, #delete_resource, #encodings_provided, #expires, #finish_request, #forbidden?, #generate_etag, #handle_exception, #is_authorized?, #is_conflict?, #known_content_type?, #known_methods, #language_chosen, #languages_provided, #last_modified, #malformed_request?, #moved_permanently?, #moved_temporarily?, #multiple_choices?, #options, #post_is_create?, #previously_existed?, #resource_exists?, #service_available?, #uri_too_long?, #valid_content_headers?, #valid_entity_length?, #validate_content_checksum, #variances
Instance Method Details
#allowed_methods ⇒ Object
3
4
5
|
# File 'lib/webmachine/spec/test_resource.rb', line 3
def allowed_methods
["GET", "PUT", "POST"]
end
|
#content_types_accepted ⇒ Object
7
8
9
10
11
12
|
# File 'lib/webmachine/spec/test_resource.rb', line 7
def content_types_accepted
[
["test/request.stringbody", :from_string],
["test/request.enumbody", :from_enum]
]
end
|
#content_types_provided ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/webmachine/spec/test_resource.rb', line 14
def content_types_provided
[
["test/response.stringbody", :to_string],
["test/response.enumbody", :to_enum],
["test/response.procbody", :to_proc],
["test/response.fiberbody", :to_fiber],
["test/response.iobody", :to_io_body],
["test/response.cookies", :to_cookies],
["test/response.request_uri", :to_request_uri]
]
end
|
#from_enum ⇒ Object
30
31
32
33
34
35
|
# File 'lib/webmachine/spec/test_resource.rb', line 30
def from_enum
response.body = "Enum: "
request.body.each do |part|
response.body += part
end
end
|
#from_string ⇒ Object
26
27
28
|
# File 'lib/webmachine/spec/test_resource.rb', line 26
def from_string
response.body = "String: #{request.body.to_s}"
end
|
#process_post ⇒ Object
Response intentionally left blank to test 204 support
38
39
40
|
# File 'lib/webmachine/spec/test_resource.rb', line 38
def process_post
true
end
|
#to_cookies ⇒ Object
66
67
68
69
70
71
72
73
|
# File 'lib/webmachine/spec/test_resource.rb', line 66
def to_cookies
response.set_cookie("cookie", "monster")
response.set_cookie("rodeo", "clown")
request.cookies["echo"] || ""
end
|
#to_enum ⇒ Object
46
47
48
|
# File 'lib/webmachine/spec/test_resource.rb', line 46
def to_enum
["Enumerable ", "response " "body"]
end
|
#to_fiber ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/webmachine/spec/test_resource.rb', line 54
def to_fiber
Fiber.new do
Fiber.yield "Fiber "
Fiber.yield "response "
"body"
end
end
|
#to_io_body ⇒ Object
62
63
64
|
# File 'lib/webmachine/spec/test_resource.rb', line 62
def to_io_body
File.new(File.expand_path('../IO_response.body', __FILE__))
end
|
#to_proc ⇒ Object
50
51
52
|
# File 'lib/webmachine/spec/test_resource.rb', line 50
def to_proc
Proc.new { "Proc response body" }
end
|
#to_request_uri ⇒ Object
75
76
77
|
# File 'lib/webmachine/spec/test_resource.rb', line 75
def to_request_uri
request.uri.to_s
end
|
#to_string ⇒ Object
42
43
44
|
# File 'lib/webmachine/spec/test_resource.rb', line 42
def to_string
"String response body"
end
|