-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: adds support for expecting on global functions and namespace functions #241
Merged
Conversation
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
Comment on lines
+316
to
+352
instance = {} | ||
instance.new = sub() | ||
end sub | ||
instance.sayHello = sub(a1, a2) | ||
print "hello" | ||
end sub | ||
return instance | ||
end function | ||
function beings_Person() | ||
instance = __beings_Person_builder() | ||
instance.new() | ||
return instance | ||
end function | ||
|
||
function beings_sayHello() | ||
if RBS_SM_1_getMocksByFunctionName()["beings_sayhello"] <> invalid | ||
result = RBS_SM_1_getMocksByFunctionName()["beings_sayhello"].callback() | ||
return result | ||
end if | ||
print "hello2" | ||
end function | ||
|
||
function sayHello() | ||
if RBS_SM_1_getMocksByFunctionName()["sayhello"] <> invalid | ||
result = RBS_SM_1_getMocksByFunctionName()["sayhello"].callback() | ||
return result | ||
end if | ||
print "hello3" | ||
end function | ||
|
||
function RBS_SM_1_getMocksByFunctionName() | ||
if m._rMocksByFunctionName = invalid | ||
m._rMocksByFunctionName = {} | ||
end if | ||
return m._rMocksByFunctionName | ||
end function | ||
`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you hate proper indentation? :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol. I honestly find if I do anything else, it won't pass the test. Always been too busy to sort it out.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds support for expecting on global functions and namespaced functions.
DOCS
Mocking global and namespaced functions
Mocking and stubbing of global functions works the same as for class methods. Please note, the functions must be in scope - you cannot mock a global function call inside of a node. So if your call crosses an observer, or callfunc bridge, it will not work. This is by design, and there are no plans to provide intra-node global or namespace mocking, at this point.
To enable this feature, set the
isGlobalMethodMockingEnabled
rooibos config parameter to true. DO NOT enable this on your ide's bsconfig.json, as it will negatively impact performance and may cause other issues. This setting is not compatible with watch mode, at this moment.Configuration
In addition to the
isGlobalMethodMockingEnabled
, you use the following config flags:isGlobalMethodMockingEfficientMode
- default to true, when set causes rooibos to modify only those functions that were mocked or stubbedglobalMethodMockingExcludedFiles
- files that rooibos will not modify, when adding global mocking or stubbing support.Known limitations:
You must include default values in your expect calls, even if your invoking code does not use them
e.g.
Note - this will be addressed shortly; pr's are welcome in the interim.
There might be some bugs, or unknown issues
Mocking, of global and namespaced functions is supported; but is a relatively new feature. It is possible that there are some scenarios that are not supported. Please raise issues in the rooibos slack channel, if you spot any anomalies.
EXAMPLE
Given
Global.bs
, with contentsOnce can now write tests like this: