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
|
# 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],
["test/response.cookies", :to_cookies]
]
end
|
#from_enum ⇒ Object
29
30
31
32
33
34
|
# File 'lib/webmachine/spec/test_resource.rb', line 29
def from_enum
response.body = "Enum: "
request.body.each do |part|
response.body += part
end
end
|
#from_string ⇒ Object
25
26
27
|
# File 'lib/webmachine/spec/test_resource.rb', line 25
def from_string
response.body = "String: #{request.body.to_s}"
end
|
#process_post ⇒ Object
Response intentionally left blank to test 204 support
37
38
39
|
# File 'lib/webmachine/spec/test_resource.rb', line 37
def process_post
true
end
|
#to_cookies ⇒ Object
65
66
67
68
69
70
71
|
# File 'lib/webmachine/spec/test_resource.rb', line 65
def to_cookies
response.set_cookie("cookie", "monster")
response.set_cookie("rodeo", "clown")
request.cookies["echo"] || ""
end
|
#to_enum ⇒ Object
45
46
47
|
# File 'lib/webmachine/spec/test_resource.rb', line 45
def to_enum
["Enumerable ", "response " "body"]
end
|
#to_fiber ⇒ Object
53
54
55
56
57
58
59
|
# File 'lib/webmachine/spec/test_resource.rb', line 53
def to_fiber
Fiber.new do
Fiber.yield "Fiber "
Fiber.yield "response "
"body"
end
end
|
#to_io ⇒ Object
61
62
63
|
# File 'lib/webmachine/spec/test_resource.rb', line 61
def to_io
StringIO.new("IO response body")
end
|
#to_proc ⇒ Object
49
50
51
|
# File 'lib/webmachine/spec/test_resource.rb', line 49
def to_proc
Proc.new { "Proc response body" }
end
|
#to_string ⇒ Object
41
42
43
|
# File 'lib/webmachine/spec/test_resource.rb', line 41
def to_string
"String response body"
end
|