Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions source/BaselineOfHOP/BaselineOfHOP.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ BaselineOfHOP >> baseline: spec [
spec requires: #('HOP-Core') ];
package: 'HOP-Extra' with: [
spec requires: #('HOP-Core') ];
package: 'HOP-Extra-Tests' with: [
spec requires: #('HOP-Extra') ];
package: 'HOP-Roassal' with: [
spec requires: #('HOP-Core') ] ]
]
Expand Down
26 changes: 26 additions & 0 deletions source/HOP-Extra-Tests/HOPTestZincHandler.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Class {
#name : 'HOPTestZincHandler',
#superclass : 'Object',
#instVars : [
'answer',
'seenRequest'
],
#category : 'HOP-Extra-Tests',
#package : 'HOP-Extra-Tests'
}

{ #category : 'accessing' }
HOPTestZincHandler >> answer: aString [
answer := aString
]

{ #category : 'public' }
HOPTestZincHandler >> handleRequest: aRequest [
seenRequest := aRequest.
^ ZnResponse ok: (ZnEntity text: answer)
]

{ #category : 'accessing' }
HOPTestZincHandler >> seenRequest [
^ seenRequest
]
29 changes: 29 additions & 0 deletions source/HOP-Extra-Tests/HOPZincHandlerAdaptorTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Class {
#name : 'HOPZincHandlerAdaptorTest',
#superclass : 'TestCase',
#category : 'HOP-Extra-Tests',
#package : 'HOP-Extra-Tests'
}

{ #category : 'tests' }
HOPZincHandlerAdaptorTest >> testAHandlerClassStillGivesAFreshOnePerRequest [
"Unchanged for every route that names a class, which is all of them today: each request gets
its own handler and nothing is carried between them."
| adaptor |
adaptor := HOPZincHandlerAdaptor new handlerClass: HOPTestZincHandler; yourself.
self deny: adaptor handler identicalTo: adaptor handler
]

{ #category : 'tests' }
HOPZincHandlerAdaptorTest >> testAPreparedHandlerIsTheOneThatAnswers [
"The point of taking an object rather than a class: whoever builds the route can prepare the
handler, and that same prepared object answers the request."
| handler adaptor request |
handler := HOPTestZincHandler new answer: 'prepared'; yourself.
adaptor := HOPZincHandlerAdaptor new handler: handler; yourself.
request := ZnRequest get: '/anything'.
self
assert: (adaptor handleRoute: (HOPRouteMatch new request: request; yourself)) entity contents
equals: 'prepared'.
self assert: handler seenRequest identicalTo: request
]
1 change: 1 addition & 0 deletions source/HOP-Extra-Tests/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : 'HOP-Extra-Tests' }
Loading