screw-unit 0.3.3 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/CHANGES +10 -0
  2. data/Rakefile +27 -25
  3. data/VERSION.yml +4 -0
  4. data/bin/screw_unit_server +14 -4
  5. data/core/EXAMPLE.html +1 -1
  6. data/core/example/spec/suite.html +1 -1
  7. data/core/lib/jquery-1.3.2.js +4376 -0
  8. data/core/lib/jquery.fn.js +2 -1
  9. data/core/lib/screw.behaviors.js +8 -7
  10. data/core/lib/screw.builder.js +34 -19
  11. data/core/lib/screw.css +1 -1
  12. data/core/lib/screw.events.js +5 -5
  13. data/core/lib/screw.matchers.js +59 -2
  14. data/core/spec/suite.html +2 -1
  15. data/core/spec/with_screw_context_spec.js +9 -0
  16. data/lib/screw_unit.rb +13 -16
  17. data/lib/screw_unit/representations.rb +2 -0
  18. data/lib/screw_unit/{resources/spec.rb → representations/spec.html.rb} +55 -39
  19. data/spec/functional/functional_spec.rb +1 -1
  20. data/spec/functional/functional_spec_helper.rb +21 -33
  21. data/spec/functional/functional_spec_server_starter.rb +68 -0
  22. data/spec/unit/js_test_core/specs/spec_file_spec.rb +52 -18
  23. data/spec/unit/unit_spec_helper.rb +24 -91
  24. data/vendor/js-test-core/CHANGES +8 -0
  25. data/vendor/js-test-core/Rakefile +1 -0
  26. data/vendor/js-test-core/lib/js_test_core.rb +22 -14
  27. data/vendor/js-test-core/lib/js_test_core/app.rb +12 -0
  28. data/vendor/js-test-core/lib/js_test_core/client.rb +21 -9
  29. data/vendor/js-test-core/lib/js_test_core/configuration.rb +35 -0
  30. data/vendor/js-test-core/lib/js_test_core/extensions.rb +1 -1
  31. data/vendor/js-test-core/lib/js_test_core/extensions/selenium/client/driver.rb +7 -0
  32. data/vendor/js-test-core/lib/js_test_core/models.rb +8 -0
  33. data/vendor/js-test-core/lib/js_test_core/models/selenium_session.rb +80 -0
  34. data/vendor/js-test-core/lib/js_test_core/representations.rb +11 -0
  35. data/vendor/js-test-core/lib/js_test_core/representations/dir.html.rb +24 -0
  36. data/vendor/js-test-core/lib/js_test_core/representations/not_found.html.rb +15 -0
  37. data/vendor/js-test-core/lib/js_test_core/representations/page.html.rb +41 -0
  38. data/vendor/js-test-core/lib/js_test_core/representations/spec.html.rb +24 -0
  39. data/vendor/js-test-core/lib/js_test_core/resources.rb +13 -7
  40. data/vendor/js-test-core/lib/js_test_core/resources/core_file.rb +19 -0
  41. data/vendor/js-test-core/lib/js_test_core/resources/file.rb +42 -20
  42. data/vendor/js-test-core/lib/js_test_core/resources/implementations_deprecation.rb +12 -0
  43. data/vendor/js-test-core/lib/js_test_core/resources/not_found.rb +35 -0
  44. data/vendor/js-test-core/lib/js_test_core/resources/resource.rb +16 -0
  45. data/vendor/js-test-core/lib/js_test_core/resources/selenium_session.rb +104 -0
  46. data/vendor/js-test-core/lib/js_test_core/resources/spec_file.rb +63 -0
  47. data/vendor/js-test-core/lib/js_test_core/resources/web_root.rb +5 -60
  48. data/vendor/js-test-core/{vendor/thin-rest/README → spec/example_core/subdir/SubDirFile.js} +0 -0
  49. data/vendor/js-test-core/spec/example_specs/custom_dir_and_suite/passing_spec.js +6 -0
  50. data/vendor/js-test-core/spec/example_specs/custom_suite.html +8 -0
  51. data/vendor/js-test-core/spec/example_specs/foo/failing_spec.js +1 -1
  52. data/vendor/js-test-core/spec/example_specs/foo/passing_spec.js +1 -1
  53. data/vendor/js-test-core/spec/spec_helpers/be_http.rb +32 -0
  54. data/vendor/js-test-core/spec/spec_helpers/example_group.rb +36 -0
  55. data/vendor/js-test-core/spec/spec_helpers/fake_selenium_driver.rb +27 -0
  56. data/vendor/js-test-core/spec/spec_helpers/show_test_exceptions.rb +22 -0
  57. data/vendor/js-test-core/spec/unit/js_test_core/client_spec.rb +35 -10
  58. data/vendor/js-test-core/spec/unit/js_test_core/configuration_spec.rb +44 -0
  59. data/vendor/js-test-core/spec/unit/js_test_core/models/selenium_session_spec.rb +85 -0
  60. data/vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb +60 -0
  61. data/vendor/js-test-core/spec/unit/js_test_core/resources/file_spec.rb +54 -63
  62. data/vendor/js-test-core/spec/unit/js_test_core/resources/implementations_deprecation_spec.rb +18 -0
  63. data/vendor/js-test-core/spec/unit/js_test_core/resources/not_found_spec.rb +51 -0
  64. data/vendor/js-test-core/spec/unit/js_test_core/resources/selenium_session_spec.rb +362 -0
  65. data/vendor/js-test-core/spec/unit/js_test_core/resources/spec_file_spec.rb +120 -0
  66. data/vendor/js-test-core/spec/unit/js_test_core/resources/web_root_spec.rb +15 -19
  67. data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +16 -149
  68. data/vendor/js-test-core/vendor/lucky-luciano/README.markdown +7 -0
  69. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano.rb +4 -0
  70. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/resource.rb +135 -0
  71. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec.rb +4 -0
  72. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb +32 -0
  73. data/vendor/js-test-core/vendor/lucky-luciano/spec/lucky_luciano/resource_spec.rb +231 -0
  74. data/vendor/js-test-core/vendor/lucky-luciano/spec/spec_helper.rb +48 -0
  75. data/vendor/js-test-core/vendor/{thin-rest → lucky-luciano}/spec/spec_suite.rb +1 -2
  76. metadata +134 -145
  77. data/core/lib/jquery-1.2.6.js +0 -3549
  78. data/lib/screw_unit/resources.rb +0 -2
  79. data/spec/unit/js_test_core/specs/spec_dir_spec.rb +0 -38
  80. data/vendor/js-test-core/lib/js_test_core/rack.rb +0 -2
  81. data/vendor/js-test-core/lib/js_test_core/rack/commonlogger.rb +0 -5
  82. data/vendor/js-test-core/lib/js_test_core/rails_server.rb +0 -22
  83. data/vendor/js-test-core/lib/js_test_core/resources/dir.rb +0 -67
  84. data/vendor/js-test-core/lib/js_test_core/resources/file_not_found.rb +0 -11
  85. data/vendor/js-test-core/lib/js_test_core/resources/runner.rb +0 -107
  86. data/vendor/js-test-core/lib/js_test_core/resources/session.rb +0 -44
  87. data/vendor/js-test-core/lib/js_test_core/resources/session_finish.rb +0 -17
  88. data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_dir.rb +0 -46
  89. data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_file.rb +0 -17
  90. data/vendor/js-test-core/lib/js_test_core/selenium.rb +0 -2
  91. data/vendor/js-test-core/lib/js_test_core/selenium/selenium_driver.rb +0 -5
  92. data/vendor/js-test-core/lib/js_test_core/server.rb +0 -50
  93. data/vendor/js-test-core/lib/js_test_core/thin.rb +0 -3
  94. data/vendor/js-test-core/lib/js_test_core/thin/backends/js_test_core_server.rb +0 -9
  95. data/vendor/js-test-core/lib/js_test_core/thin/js_test_core_connection.rb +0 -8
  96. data/vendor/js-test-core/spec/unit/js_test_core/rails_server_spec.rb +0 -45
  97. data/vendor/js-test-core/spec/unit/js_test_core/resources/dir_spec.rb +0 -52
  98. data/vendor/js-test-core/spec/unit/js_test_core/resources/file_not_found_spec.rb +0 -16
  99. data/vendor/js-test-core/spec/unit/js_test_core/resources/runners/runner_spec.rb +0 -303
  100. data/vendor/js-test-core/spec/unit/js_test_core/resources/session_finish_spec.rb +0 -79
  101. data/vendor/js-test-core/spec/unit/js_test_core/resources/session_spec.rb +0 -82
  102. data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_dir_spec.rb +0 -105
  103. data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_file_spec.rb +0 -42
  104. data/vendor/js-test-core/spec/unit/js_test_core/server_spec.rb +0 -117
  105. data/vendor/js-test-core/spec/unit/thin/js_test_core_connection_spec.rb +0 -6
  106. data/vendor/js-test-core/vendor/thin-rest/CHANGES +0 -2
  107. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest.rb +0 -9
  108. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/connection.rb +0 -116
  109. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions.rb +0 -3
  110. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions/object.rb +0 -21
  111. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resource.rb +0 -108
  112. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resource_invalid.rb +0 -4
  113. data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/routing_error.rb +0 -5
  114. data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/connection_spec.rb +0 -207
  115. data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/resource_spec.rb +0 -127
  116. data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest_spec_helper.rb +0 -124
@@ -1,3 +0,0 @@
1
- Dir["#{File.dirname(__FILE__)}/extensions/*.rb"].each do |file|
2
- require file
3
- end
@@ -1,21 +0,0 @@
1
- # From Mauricio Fernandez.
2
- class Object
3
- module InstanceExecHelper; end
4
- include InstanceExecHelper
5
- def instance_exec(*args, &block)
6
- begin
7
- old_critical, Thread.critical = Thread.critical, true
8
- n = 0
9
- n += 1 while respond_to?(mname="__instance_exec#{n}")
10
- InstanceExecHelper.module_eval{ define_method(mname, &block) }
11
- ensure
12
- Thread.critical = old_critical
13
- end
14
- begin
15
- ret = send(mname, *args)
16
- ensure
17
- InstanceExecHelper.module_eval{ remove_method(mname) } rescue nil
18
- end
19
- ret
20
- end
21
- end
@@ -1,108 +0,0 @@
1
- module ThinRest
2
- class Resource
3
- class << self
4
- def property(*names)
5
- names.each do |name|
6
- my_properties << name.to_sym
7
-
8
- define_method name do
9
- env[name]
10
- end
11
-
12
- define_method "#{name}=" do |new_value|
13
- env[name] = new_value
14
- end
15
- end
16
- end
17
-
18
- def properties
19
- if superclass.respond_to?(:properties)
20
- superclass.properties | my_properties
21
- else
22
- my_properties
23
- end
24
- end
25
-
26
- def route(name, resource_type_name=nil, &block)
27
- routes[name] = block || lambda do |env, name|
28
- resource_type = resource_type_name.split('::').inject(Object) do |mod, next_mod_name|
29
- mod.const_get(next_mod_name)
30
- end
31
- resource_type.new(env)
32
- end
33
- end
34
-
35
- def routes
36
- @routes ||= {}
37
- end
38
-
39
- protected
40
- def my_properties
41
- @my_properties ||= []
42
- end
43
-
44
- def handle_dequeue_and_process_error(command, error)
45
- if command.connection
46
- command.connection.handle_error error
47
- else
48
- super
49
- end
50
- end
51
- end
52
- ANY = Object.new
53
-
54
- property :connection
55
- attr_reader :env
56
-
57
- def initialize(env={})
58
- @env = env
59
- env.each do |name, value|
60
- if self.class.properties.include?(name.to_sym)
61
- instance_variable_set("@#{name}", value)
62
- end
63
- end
64
- after_initialize
65
- end
66
-
67
- def request; connection.request; end
68
- def response; connection.response; end
69
- def rack_request; connection.rack_request; end
70
-
71
- def get
72
- connection.send_head
73
- connection.send_body(do_get || "")
74
- end
75
-
76
- def post
77
- connection.send_head
78
- connection.send_body(do_post || "")
79
- end
80
-
81
- def put
82
- connection.send_head
83
- connection.send_body(do_put || "")
84
- end
85
-
86
- def delete
87
- connection.send_head
88
- connection.send_body(do_delete || "")
89
- end
90
-
91
- def locate(name)
92
- route_handler = self.class.routes[name] || self.class.routes[ANY]
93
- raise RoutingError, "Invalid route: #{connection.rack_request.path_info} ; name: #{name}" unless route_handler
94
- instance_exec(env, name, &route_handler)
95
- end
96
-
97
- def unbind
98
- end
99
-
100
- def ==(other)
101
- other.class == self.class && other.env == env
102
- end
103
-
104
- protected
105
- def after_initialize
106
- end
107
- end
108
- end
@@ -1,4 +0,0 @@
1
- module ThinRest
2
- class ResourceInvalid < StandardError
3
- end
4
- end
@@ -1,5 +0,0 @@
1
- module ThinRest
2
- class RoutingError < RuntimeError
3
-
4
- end
5
- end
@@ -1,207 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../thin_rest_spec_helper")
2
-
3
- module ThinRest
4
- describe Connection do
5
- attr_reader :connection
6
-
7
- describe "#process" do
8
- attr_reader :result
9
- before do
10
- @connection = create_connection
11
- stub(connection).socket_address {'0.0.0.0'}
12
-
13
- @result = ""
14
- stub(EventMachine).send_data do |signature, data, data_length|
15
- result << data
16
- end
17
- end
18
-
19
- context "when the call is successful" do
20
- context "when the request has Connection: close" do
21
- it "sends the response to the socket with a Connection: close response header" do
22
- mock(connection).close_connection_after_writing
23
- connection.receive_data "GET /subresource HTTP/1.1\r\nConnection: close\r\nHost: _\r\n\r\n"
24
- result.should include("GET response")
25
- result.should include("Connection: close")
26
- end
27
-
28
- it "closes the connection" do
29
- mock(connection).close_connection_after_writing
30
- connection.receive_data "GET /subresource HTTP/1.1\r\nConnection: close\r\nHost: _\r\n\r\n"
31
- end
32
- end
33
-
34
- context "when the request does not have Connection: close" do
35
- it "sends the response to the socket without a Connection: close response header" do
36
- connection.receive_data "GET /subresource HTTP/1.1\r\nHost: _\r\n\r\n"
37
- result.should include("GET response")
38
- result.should_not include("Connection: close")
39
- end
40
-
41
- it "does not close the connection" do
42
- dont_allow(connection).close_connection_after_writing
43
- connection.receive_data "GET /subresource HTTP/1.1\r\nHost: _\r\n\r\n"
44
- end
45
-
46
- context "when a second request is made" do
47
- it "sends the response for the second request and not for the first request" do
48
- connection.receive_data "GET /subresource HTTP/1.1\r\nHost: _\r\n\r\n"
49
- result.should include("GET response")
50
- result.should_not include("Another GET response")
51
-
52
- connection.receive_data "GET /another_subresource HTTP/1.1\r\nHost: _\r\n\r\n"
53
- result.should include("Another GET response")
54
- end
55
- end
56
- end
57
- end
58
-
59
- context "when the call raises an error" do
60
- it "logs the error and closes the connection" do
61
- error = nil
62
- mock(connection).log_error(is_a(Exception)) do |error_arg|
63
- error = error_arg
64
- end
65
- mock(connection).close_connection
66
-
67
- connection.receive_data "GET /error_subresource HTTP/1.1\r\nHost: _\r\n\r\n"
68
- error.message.should =~ Regexp.new("/error_subresource")
69
- end
70
- end
71
- end
72
-
73
- describe "#send_head" do
74
- before do
75
- @connection = create_connection
76
- stub(EventMachine).close_connection
77
- end
78
-
79
- context "when passed no arguments" do
80
- it "responds with a 200 HTTP header excluding the Content-Length" do
81
- expected_header = "HTTP/1.1 200 OK\r\nServer: Thin Rest Server\r\n"
82
- mock(EventMachine).send_data( connection.signature, expected_header, expected_header.length ) {expected_header.length}
83
- connection.send_head
84
- end
85
- end
86
-
87
- context "when passed 301" do
88
- it "responds with a 301 HTTP header excluding the Content-Length" do
89
- expected_header = "HTTP/1.1 301 OK\r\nServer: Thin Rest Server\r\n"
90
- mock(EventMachine).send_data( connection.signature, expected_header, expected_header.length ) {expected_header.length}
91
- connection.send_head(301)
92
- end
93
- end
94
-
95
- context "when passed additional parameters" do
96
- it "responds with the additional parameters in the header" do
97
- expected_header = "HTTP/1.1 301 OK\r\nServer: Thin Rest Server\r\nLocation: http://google.com\r\n"
98
- mock(EventMachine).send_data( connection.signature, expected_header, expected_header.length ) {expected_header.length}
99
- connection.send_head(301, :Location => "http://google.com")
100
- end
101
-
102
- context "when not passed Content-length" do
103
- it 'does not end with \r\n\r\n' do
104
- expected_header = "HTTP/1.1 301 OK\r\nServer: Thin Rest Server\r\nLocation: http://google.com\r\n"
105
- mock(EventMachine).send_data( connection.signature, expected_header, expected_header.length ) {expected_header.length}
106
- connection.send_head(301, :Location => "http://google.com")
107
- end
108
- end
109
-
110
- context "when passed Content-Length" do
111
- it 'when passed a Symbol representation of Content-Length ends with \r\n\r\n' do
112
- expected_header = "HTTP/1.1 301 OK\r\nServer: Thin Rest Server\r\nContent-Length: 10\r\n\r\n"
113
- mock(EventMachine).send_data( connection.signature, expected_header, expected_header.length ) {expected_header.length}
114
- connection.send_head(301, :'Content-Length' => 10)
115
- end
116
-
117
- it 'when passed a String representation of Content-Length ends with \r\n\r\n' do
118
- expected_header = "HTTP/1.1 301 OK\r\nServer: Thin Rest Server\r\nContent-Length: 10\r\n\r\n"
119
- mock(EventMachine).send_data( connection.signature, expected_header, expected_header.length ) {expected_header.length}
120
- connection.send_head(301, 'Content-Length' => 10)
121
- end
122
- end
123
- end
124
- end
125
-
126
- describe "#send_body" do
127
- before do
128
- @connection = create_connection
129
- stub(EventMachine).close_connection
130
- end
131
-
132
- it "responds with Content-Length and the body" do
133
- data = "The data"
134
- header = "Content-Length: #{data.length}\r\n\r\n"
135
-
136
- mock(EventMachine).send_data( connection.signature, header, header.length ) {header.length}
137
- mock(EventMachine).send_data( connection.signature, data, data.length ) {data.length}
138
-
139
- connection.send_body data
140
- end
141
- end
142
-
143
- describe "#unbind" do
144
- attr_reader :game_session
145
-
146
- before do
147
- stub_send_data
148
- stub(EventMachine).close_connection
149
- @connection = create_connection
150
- params = "param_1=1&param_2=2"
151
- body = "#{params}\r\n"
152
- connection.receive_data("POST /subresource HTTP/1.1\r\nHost: _\r\n\r\n#{body}")
153
- end
154
-
155
- it "calls connection_finished on the backend to protect against memory leaks" do
156
- mock(connection.backend).connection_finished(connection)
157
- connection.unbind
158
- end
159
-
160
- it "does not send data or add a timer of any type" do
161
- dont_allow(EventMachine).send_data
162
- dont_allow(EventMachine).add_timer
163
-
164
- connection.unbind
165
- end
166
- end
167
-
168
- describe "#handle_error" do
169
- before do
170
- @connection = create_connection
171
- Thin::Logging.silent = true
172
- end
173
-
174
- it "logs the error" do
175
- error = RuntimeError.new("Unexpected Error")
176
- stub(error).backtrace(caller)
177
-
178
- stub(connection).warn
179
- mock.proxy(connection).log_error(error)
180
- mock.proxy(connection).log_error(anything)
181
-
182
- connection.handle_error(error)
183
- end
184
- end
185
-
186
- describe "#persistent?" do
187
- before do
188
- @connection = create_connection
189
- stub(connection).socket_address {'0.0.0.0'}
190
- end
191
-
192
- context "when #request.persistent? is true" do
193
- it "returns true" do
194
- stub(connection.request).persistent? {true}
195
- connection.should be_persistent
196
- end
197
- end
198
-
199
- context "when #request.persistent? is false" do
200
- it "returns false" do
201
- stub(connection.request).persistent? {false}
202
- connection.should_not be_persistent
203
- end
204
- end
205
- end
206
- end
207
- end
@@ -1,127 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../thin_rest_spec_helper")
2
-
3
- module ThinRest
4
- describe Resource do
5
- attr_reader :connection, :root
6
- self.thin_logging = true
7
- before do
8
- @connection = create_connection
9
- stub(EventMachine).close_connection
10
- @root = Root.new(:connection => connection)
11
- end
12
-
13
- describe ".property" do
14
- it "creates a reader that takes its value from its env property" do
15
- root.env[:connection].should == connection
16
- root.connection.should == root.env[:connection]
17
- end
18
-
19
- it "creates a writer that sets its passed in value to its env property" do
20
- another_connection = create_connection
21
- root.connection = another_connection
22
- root.connection.should == another_connection
23
- root.env[:connection].should == another_connection
24
- end
25
- end
26
-
27
- describe "#locate" do
28
- context "/subresource - route is defined using a String" do
29
- it "returns an instance of Subresource" do
30
- root.locate("subresource").class.should == Subresource
31
- end
32
- end
33
-
34
- context "/block_subresource - route is defined using a block" do
35
- it "returns an instance of BlockSubresource" do
36
- root.locate("block_subresource").class.should == BlockSubresource
37
- end
38
-
39
- it "executes the block within the instance of the Resource" do
40
- root.foobar.should_not be_nil
41
- root.locate("block_subresource").foobar.should == root.foobar
42
- end
43
- end
44
-
45
- context "/no_handler_subresource - route is not defined" do
46
- it "raises a RoutingError" do
47
- lambda do
48
- root.locate("no_handler_subresource")
49
- end.should raise_error(RoutingError)
50
- end
51
- end
52
-
53
- context "/wrong_property - passed in property not defined" do
54
- it "does not set an instance variable named after the wrong property" do
55
- resource = root.locate("wrong_property")
56
- resource.env.should == {:connection => connection, :baz => "wrong_property"}
57
- resource.instance_variable_get("@connection").should == connection
58
- resource.instance_variable_get("@baz").should be_nil
59
- end
60
- end
61
- end
62
-
63
- describe "Delegations" do
64
- describe "#request" do
65
- it "delegates to #connection" do
66
- root.request.should == connection.request
67
- end
68
- end
69
-
70
- describe "#response" do
71
- it "delegates to #connection" do
72
- root.response.should == connection.response
73
- end
74
- end
75
-
76
- describe "#rack_request" do
77
- it "delegates to #connection" do
78
- root.rack_request.should == connection.rack_request
79
- end
80
- end
81
- end
82
-
83
- describe "GET /subresource" do
84
- it "sends the GET response for the resource" do
85
- mock(connection).send_data(connection.head(200, {}))
86
- expected_data = "GET response"
87
- expected_content_length = "Content-Length: #{expected_data.length}\r\n\r\n"
88
- mock(connection).send_data(expected_content_length) {expected_content_length.length}
89
- mock(connection).send_data(expected_data) {expected_data.length}
90
- connection.receive_data("GET /subresource HTTP/1.1\r\nHost: _\r\n\r\n")
91
- end
92
- end
93
-
94
- describe "POST /subresource" do
95
- it "sends the POST response for the resource" do
96
- mock(connection).send_data(connection.head(200, {}))
97
- expected_data = "POST response"
98
- expected_content_length = "Content-Length: #{expected_data.length}\r\n\r\n"
99
- mock(connection).send_data(expected_content_length) {expected_content_length.length}
100
- mock(connection).send_data(expected_data) {expected_data.length}
101
- connection.receive_data("POST /subresource HTTP/1.1\r\nHost: _\r\n\r\n")
102
- end
103
- end
104
-
105
- describe "PUT /subresource" do
106
- it "sends the PUT response for the resource" do
107
- mock(connection).send_data(connection.head(200, {}))
108
- expected_data = "PUT response"
109
- expected_content_length = "Content-Length: #{expected_data.length}\r\n\r\n"
110
- mock(connection).send_data(expected_content_length) {expected_content_length.length}
111
- mock(connection).send_data(expected_data) {expected_data.length}
112
- connection.receive_data("PUT /subresource HTTP/1.1\r\nHost: _\r\n\r\n")
113
- end
114
- end
115
-
116
- describe "DELETE /subresource" do
117
- it "sends the DELETE response for the resource" do
118
- mock(connection).send_data(connection.head(200, {}))
119
- expected_data = "DELETE response"
120
- expected_content_length = "Content-Length: #{expected_data.length}\r\n\r\n"
121
- mock(connection).send_data(expected_content_length) {expected_content_length.length}
122
- mock(connection).send_data(expected_data) {expected_data.length}
123
- connection.receive_data("DELETE /subresource HTTP/1.1\r\nHost: _\r\n\r\n")
124
- end
125
- end
126
- end
127
- end