Skip to content

Commit

Permalink
. t experiment with crappy code
Browse files Browse the repository at this point in the history
  • Loading branch information
dionAngelo committed Jan 31, 2024
1 parent d719d60 commit dcf3281
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
13 changes: 11 additions & 2 deletions src/Approvaltests-Tests/SimpleTest.class.st
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
Class {
#name : #SimpleTest,
#superclass : #TestCase,
#classVars : [
'TestVerifyApproved'
],
#category : #'Approvaltests-Tests'
}

{ #category : #'as yet unclassified' }
SimpleTest class >> _testVerify_Approved [ ^42
]

{ #category : #tests }
SimpleTest >> test3Is3 [

self assert: 3 equals: 3
TestVerifyApproved := 10 atRandom.

self assert: 3 equals: 3.
]

{ #category : #tests }
SimpleTest >> testVerify [

"Approvals verify: 'Hello, world.'"

self assert: true.
Approvals verify: 'Hello, world.'.
]
36 changes: 22 additions & 14 deletions src/Approvaltests/ApprovalNamer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,28 @@ Class {
#category : #Approvaltests
}

{ #category : #'as yet unclassified' }
{ #category : #accessing }
ApprovalNamer class >> findTestMethod: aContext [
| aReceiver |

aContext ifNil: [ ^nil ].

aReceiver := aContext receiver.
^(aReceiver isKindOf: TestCase)
ifTrue:[ aReceiver ]
ifFalse:[self findTestMethod: aContext sender]

]

{ #category : #accessing }
ApprovalNamer class >> getApprovedText [
| methodName sender |
sender := self findTestMethod: thisContext sender.
methodName := '_' , sender selector , '_Approved'.
^ sender class perform: methodName asSymbol
]

{ #category : #accessing }
ApprovalNamer >> approvalName [
| className methodName testName sender|

Expand All @@ -24,19 +45,6 @@ ApprovalNamer >> approvedFileName [
^ sourceDirectory , '/Approvaltests-Tests/' , name , '.approved'
]

{ #category : #'as yet unclassified' }
ApprovalNamer >> findTestMethod: aContext [
| aReceiver |

aContext ifNil: [ ^nil ].

aReceiver := aContext receiver.
^(aReceiver isKindOf: TestCase)
ifTrue:[ aReceiver ]
ifFalse:[self findTestMethod: aContext sender]

]

{ #category : #'as yet unclassified' }
ApprovalNamer >> receivedFileName [
]
4 changes: 2 additions & 2 deletions src/Approvaltests/Approvals.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Approvals class >> verify: anObject index: anInteger [

]

{ #category : #'as yet unclassified' }
{ #category : #accessing }
Approvals class >> verify: anObject options: anOptions [

self verify: anObject options: Options new.
self assert:anObject equals: ApprovalNamer getApprovedText.

]

Expand Down

0 comments on commit dcf3281

Please sign in to comment.