Skip to content

Commit

Permalink
Merge pull request #18 from dionisiydk/dev
Browse files Browse the repository at this point in the history
Object sender spec fix
  • Loading branch information
dionisiydk authored Jul 5, 2019
2 parents 6a98772 + 2c45e92 commit c8d2bad
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 14 deletions.
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].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SystemOrganization addCategory: 'Mocketry-Domain-Tests'!
SystemOrganization addCategory: #'Mocketry-Domain-Tests'!
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}
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
2 changes: 1 addition & 1 deletion Mocketry-Specs-Tests.package/monticello.meta/categories.st
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SystemOrganization addCategory: 'Mocketry-Specs-Tests'!
SystemOrganization addCategory: #'Mocketry-Specs-Tests'!
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
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

0 comments on commit c8d2bad

Please sign in to comment.