Skip to content

Commit

Permalink
fixed findTestMethod
Browse files Browse the repository at this point in the history
  • Loading branch information
Dion Stewart committed Nov 18, 2023
1 parent 7c0ae2d commit 038dc7b
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 7 deletions.
14 changes: 14 additions & 0 deletions src/Approvaltests-Tests/ApprovalNamerTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Class {
#name : #ApprovalNamerTest,
#superclass : #TestCase,
#category : #'Approvaltests-Tests'
}

{ #category : #tests }
ApprovalNamerTest >> testApprovedFile [
| namer approvedFileName |

namer := ApprovalNamer new.
approvedFileName := namer approvedFileName, '.txt'.
self assert: (File exists: approvedFileName).
]
8 changes: 4 additions & 4 deletions src/Approvaltests-Tests/SimpleTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ self assert: 3 equals: 3
]

{ #category : #tests }
SimpleTest >> testName [
| namer |
SimpleTest >> testVerify [

"Approvals verify: 'Hello, world.'"

namer := ApprovalNamer new.
self assert: namer approvalName equals: 'SimpleTest.testName'.
self assert: true.
]
35 changes: 32 additions & 3 deletions src/Approvaltests/ApprovalNamer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,39 @@ Class {

{ #category : #'as yet unclassified' }
ApprovalNamer >> approvalName [
| className methodName testName |
| className methodName testName sender|

className := thisContext sender methodClass name.
methodName := thisContext sender selector.
sender := self findTestMethod: thisContext sender.
className := sender className.
methodName := sender selector.
testName := className , '.', methodName .
^testName
]

{ #category : #'as yet unclassified' }
ApprovalNamer >> approvedFileName [
" ^self approvalName."

| name |
name := self approvalName.

^ '/Users/dionstewart/Documents/Pharo/images/ApprovalTestsPharo 11.0 - 64bit/pharo-local/iceberg/approvals/ApprovalTests.pharo.StarterProject/src/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 [
]
33 changes: 33 additions & 0 deletions src/Approvaltests/Approvals.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Class {
#name : #Approvals,
#superclass : #Object,
#category : #Approvaltests
}

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

self verify: anObject options: (Options new)

]

{ #category : #'as yet unclassified' }
Approvals class >> verify: anObject index: anInteger [



]

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

self verify: anObject options: Options new.

]

{ #category : #'as yet unclassified' }
Approvals class >> verify: anObject with: anInteger [



]
5 changes: 5 additions & 0 deletions src/Approvaltests/Options.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : #Options,
#superclass : #Object,
#category : #Approvaltests
}
5 changes: 5 additions & 0 deletions src/Approvaltests/TextWriter.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : #TextWriter,
#superclass : #Object,
#category : #Approvaltests
}

0 comments on commit 038dc7b

Please sign in to comment.