Znock.class.st 967 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. Class {
  2. #name : #Znock,
  3. #superclass : #Object,
  4. #instVars : [
  5. 'expectations'
  6. ],
  7. #classInstVars : [
  8. 'default'
  9. ],
  10. #category : #Znock
  11. }
  12. { #category : #accessing }
  13. Znock class >> default [
  14. ^ default ifNil: [ default := self new ]
  15. ]
  16. { #category : #accessing }
  17. Znock >> addExpectation: aZnClient [
  18. ^ self expectations add: aZnClient
  19. ]
  20. { #category : #public }
  21. Znock >> baseFor: descriptor [
  22. ^ ZnockBase in: self url: descriptor asHostFirstUrl
  23. ]
  24. { #category : #operations }
  25. Znock >> consumeExpectationFor: aZnockClient [
  26. ^ self expectations
  27. detect: [ :one | aZnockClient matches: one ]
  28. ifFound: [ :one | expectations remove: one. one ]
  29. ifNone: [ nil ]
  30. ]
  31. { #category : #accessing }
  32. Znock >> expectations [
  33. ^ expectations ifNil: [ expectations := OrderedCollection new ]
  34. ]
  35. { #category : #public }
  36. Znock >> pendingExpectations [
  37. ^ self expectations reject: #isOptional
  38. ]
  39. { #category : #public }
  40. Znock >> removeAll [
  41. self expectations removeAll
  42. ]