Skip to content

Commit bb233d2

Browse files
authored
Merge pull request #71 from pavel-krivanek/70-createDefaultOrganizationFrom
70-createDefaultOrganizationFrom
2 parents d4c6161 + f8c3250 commit bb233d2

File tree

4 files changed

+56
-31
lines changed

4 files changed

+56
-31
lines changed

MonticelloTonel-Core.package/TonelWriter.class/instance/createDefaultOrganizationFrom..st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ createDefaultOrganizationFrom: aCollection
55
"simplest case, I answer the clas definition"
66
snapshot definitions
77
detect: #isClassDefinition
8-
ifFound: [ :each | ^ each category ].
8+
ifFound: [ :each | ^ MCOrganizationDefinition categories: { each category } ].
99

1010
^ self createDefaultOrganizationFromDefinition: (snapshot definitions
1111
detect: #isMethodDefinition
12-
ifNone: [ self error: 'cannot determine package name from empty snapshot' ])
12+
ifNone: [ self error: 'cannot determine package name from empty snapshot' ])
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
tests
2+
checkFilesStructureIn: aFileReference
3+
4+
| nl |
5+
6+
self assert: (aFileReference / 'MonticelloMocks') exists.
7+
self
8+
assert: ((aFileReference / 'MonticelloMocks') entries collect: #basename)
9+
equals: #(
10+
'MCMockASubclass.class.st'
11+
'MCMockClassA.class.st'
12+
'MCMockClassB.class.st'
13+
'MCMockClassD.class.st'
14+
'MCMockClassE.class.st'
15+
'MCMockClassF.class.st'
16+
'MCMockClassG.class.st'
17+
'MCMockClassH.class.st'
18+
'MCMockClassI.class.st'
19+
'MCSnapshotTest.extension.st'
20+
'package.st').
21+
22+
nl := OSPlatform current lineEnding.
23+
self
24+
assert: (aFileReference / 'MonticelloMocks' / 'MCMockClassA.class.st') contents
25+
equals: (self expectedMCMockClassAClassSt withLineEndings: nl).
26+
self
27+
assert: (aFileReference / 'MonticelloMocks' / 'MCMockASubclass.class.st') contents
28+
equals: (self expectedMCMockASubclassClassSt withLineEndings: nl).
29+
self
30+
assert: (aFileReference / 'MonticelloMocks' / 'MCSnapshotTest.extension.st') contents
31+
equals: (self expectedMCSnapshotTestExtensionSt withLineEndings: nl)
Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,9 @@
11
tests
22
testWriteSnapshot
3-
| writer mem nl |
3+
| writer memoryFileReference |
44

5-
mem := FileSystem memory root.
6-
writer := self actualClass on: mem.
5+
memoryFileReference := FileSystem memory root.
6+
writer := self actualClass on: memoryFileReference.
77
writer writeSnapshot: self mockSnapshot.
88

9-
self assert: (mem / 'MonticelloMocks') exists.
10-
self
11-
assert: ((mem / 'MonticelloMocks') entries collect: #basename)
12-
equals: #(
13-
'MCMockASubclass.class.st'
14-
'MCMockClassA.class.st'
15-
'MCMockClassB.class.st'
16-
'MCMockClassD.class.st'
17-
'MCMockClassE.class.st'
18-
'MCMockClassF.class.st'
19-
'MCMockClassG.class.st'
20-
'MCMockClassH.class.st'
21-
'MCMockClassI.class.st'
22-
'MCSnapshotTest.extension.st'
23-
'package.st').
24-
25-
nl := OSPlatform current lineEnding.
26-
self
27-
assert: (mem / 'MonticelloMocks' / 'MCMockClassA.class.st') contents
28-
equals: (self expectedMCMockClassAClassSt withLineEndings: nl).
29-
self
30-
assert: (mem / 'MonticelloMocks' / 'MCMockASubclass.class.st') contents
31-
equals: (self expectedMCMockASubclassClassSt withLineEndings: nl).
32-
self
33-
assert: (mem / 'MonticelloMocks' / 'MCSnapshotTest.extension.st') contents
34-
equals: (self expectedMCSnapshotTestExtensionSt withLineEndings: nl)
9+
self checkFilesStructureIn: memoryFileReference
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
tests
2+
testWriteSnapshotWithoutOrganization
3+
"test if the exported code has correct structure even if the Monticello snapshot does not have
4+
a proper organization definition so the structure must be taken from the category names.
5+
See TonelWriter>>#createDefaultOrganizationFrom:"
6+
7+
| aSnapshot memoryFileReference writer |
8+
9+
aSnapshot := self mockSnapshot copy.
10+
(aSnapshot definitions select: #isOrganizationDefinition) do: [ :each |
11+
aSnapshot definitions remove: each ].
12+
13+
memoryFileReference := FileSystem memory root.
14+
writer := self actualClass on: memoryFileReference.
15+
writer writeSnapshot: self mockSnapshot.
16+
17+
self checkFilesStructureIn: memoryFileReference
18+
19+

0 commit comments

Comments
 (0)