-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from dionisiydk/dev
Object sender spec fix
- Loading branch information
Showing
7 changed files
with
50 additions
and
14 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...stance/testValidationThatObjectIsResultOfDeepMessageSendWhichWasAlsoReturnedFromSender.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
tests | ||
testValidationThatObjectIsResultOfDeepMessageSendWhichWasAlsoReturnedFromSender | ||
|
||
| result rect | | ||
rect := 0@0 corner: mock. | ||
rect stub. | ||
|
||
result := rect right. | ||
|
||
result should beReturnedFrom: [mock x]. | ||
result should beReturnedFrom: [rect right]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
SystemOrganization addCategory: 'Mocketry-Domain-Tests'! | ||
SystemOrganization addCategory: #'Mocketry-Domain-Tests'! |
13 changes: 13 additions & 0 deletions
13
...ests.package/SpecOfExpectedObjectSenderTests.class/instance/testMatchesMultipleSenders.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
tests | ||
testMatchesMultipleSenders | ||
|
||
| spec expectedSenderMessage anotherSenderMessage | | ||
spec := SpecOfExpectedObjectSender for: #object returnedFrom: ( | ||
SpecOfExpectedMessage from: (MockOccurredMessage receiver: #receiver selector: #selector)). | ||
|
||
expectedSenderMessage := MockOccurredMessage receiver: #receiver selector: #selector. | ||
expectedSenderMessage result: #object asOccurredMessageResult. | ||
anotherSenderMessage := MockOccurredMessage receiver: #receiver selector: #anotherSelector. | ||
anotherSenderMessage result: #object asOccurredMessageResult. | ||
|
||
spec should be matches: {anotherSenderMessage. expectedSenderMessage} |
15 changes: 15 additions & 0 deletions
15
.../SpecOfExpectedObjectSenderTests.class/instance/testSucceedValidationOfMultipleSenders.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
tests | ||
testSucceedValidationOfMultipleSenders | ||
|
||
| spec result expectedSenderMessage anotherSenderMessage | | ||
spec := SpecOfExpectedObjectSender for: #object returnedFrom: ( | ||
SpecOfExpectedMessage from: (MockOccurredMessage receiver: #receiver selector: #selector)). | ||
|
||
expectedSenderMessage := MockOccurredMessage receiver: #receiver selector: #selector. | ||
expectedSenderMessage result: #object asOccurredMessageResult. | ||
anotherSenderMessage := MockOccurredMessage receiver: #receiver selector: #anotherSelector. | ||
anotherSenderMessage result: #object asOccurredMessageResult. | ||
|
||
result := spec validate: { anotherSenderMessage. expectedSenderMessage }. | ||
|
||
result should be: SpecOfValidationResult success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
SystemOrganization addCategory: 'Mocketry-Specs-Tests'! | ||
SystemOrganization addCategory: #'Mocketry-Specs-Tests'! |
8 changes: 3 additions & 5 deletions
8
Mocketry-Specs.package/SpecOfExpectedObjectSender.class/instance/basicMatches..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
testing | ||
basicMatches: occurredMessages | ||
|
||
| actualSender | | ||
actualSender := occurredMessages | ||
detect: [:each | each hasReturnedValueLike: object] | ||
ifNone: [^false]. | ||
| actualSenders | | ||
actualSenders := occurredMessages select: [:each | each hasReturnedValueLike: object]. | ||
|
||
^requiredSender basicMatches: { actualSender } | ||
^requiredSender basicMatches: actualSenders |
13 changes: 6 additions & 7 deletions
13
Mocketry-Specs.package/SpecOfExpectedObjectSender.class/instance/validate..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
validation | ||
validate: occurredMessages | ||
| actualSender success | | ||
actualSender := occurredMessages | ||
detect: [ :each | each hasReturnedValueLike: object ] | ||
ifNone: [ ^ self validateRequiredSenderFor: occurredMessages ]. | ||
|
||
success := requiredSender matches: {actualSender}. | ||
| actualSenders success | | ||
actualSenders := occurredMessages select: [ :each | each hasReturnedValueLike: object ]. | ||
actualSenders ifEmpty: [ ^ self validateRequiredSenderFor: occurredMessages ]. | ||
|
||
success := requiredSender matches: actualSenders. | ||
success ifTrue: [ ^ SpecOfValidationResult success ]. | ||
|
||
^ SpecOfWrongObjectSender spec: self for: occurredMessages wrongSender: actualSender | ||
^ SpecOfWrongObjectSender spec: self for: occurredMessages wrongSender: actualSenders last |