Members
-
INSTANCE
-
instance string
Example
mock("obj", mock.INSTANCE);
-
OBJECT
-
object string
Example
mock("obj", mock.OBJECT);
Methods
-
anything()
-
anything
return special string.
If you useanything
inwith_param
thatshould_receive
execute method regardless of parameter value.Returns:
- '_js_mock_anything_param'
- Type
- String
Example
mock("obj").should_receive("something").with_param(1,mock.anything()).and_return("1");
-
mock(name, type)
-
create mock in global.
Parameters:
Name Type Description name
string | object | function | class Mock object of name, object, function or class.
type
string Mock object of type. - mock.INSTANCE, mock.OBJECT(defalut)
Returns:
- Type
- Mock
Example
// If `name` is string and `global` not found `name` object that mock create object in global. mock("obj").should_receive("something"); mock("Sample",mock.INSTANCE).should_receive("something"); // If `name` is object that mock don`t create object. mock(obj).should_receive("something"); mock(zlass).should_receive("something");