Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
A is a nodejs module which consists of A mocking framework and A testing framework.
partial mock
var original = function() {
return 'realValue';
}
var mock = require('a').mock;
original = mock(original);
mock.expect().return('fake');
original(); //returns 'fake'
original(); //returns 'realValue'
strict mock
var original = function() {
return 'realValue';
}
var mock = require('a').mock;
original = mock();
mock.expect().return('fake');
original(); //returns 'fake'
original(); //throws unexpected arguments
strict mock with arguments
var original = function(arg) {
return 'realValue';
}
var mock = require('a').mock;
original = mock();
mock.expect('testValue1').return('fake1');
mock.expect('testValue2').return('fake2');
original('testValue1'); //returns 'fake1'
original('testValue2'); //returns 'fake2'
original(); //throws unexpected arguments
original('foo'); //throws unexpected arguments
strict mock with multiple arguments
var original = function(arg1, arg2) {
return 'realValue';
}
var mock = require('a').mock;
original = mock();
mock.expect('firstArg1', 'secondArg1').return('fake1');
mock.expect('firstArg2', 'secondArg2').return('fake2');
original('firstArg1', 'secondArg1'); //returns 'fake1'
original('firstArg2', 'secondArg2'); //returns 'fake2'
original('foo'); //throws unexpected arguments
original('foo', 'bar'); //throws unexpected arguments
strict mock with repeats
var original = function() {
return 'realValue';
}
var mock = require('a').mock;
original = mock();
mock.expect().return('fake').repeat(2);
original(); //returns 'fake'
original(); //returns 'fake'
original(); //throws unexpected arguments
strict mock ignoring arguments
var original = function(arg) {
return 'realValue';
}
var mock = require('a').mock;
original = mock();
mock.expectAnything().return('fake1');
original('someRandomValue'); //returns 'fake1'
original(); //throws unexpected arguments
strict mock with interceptor
var original = function(arg) {
return 'realValue';
}
var mock = require('a').mock;
original = mock();
mock.expect('testValue').whenCalled(onCalled).return('fake1');
function onCalled(arg) {
//arg == 'testValue'
}
original('someRandomValue'); //returns 'fake1'
original(); //throws unexpected arguments
strict mock - advanced scenario
var original = function(arg, callback) {
return 'realValue';
}
var mock = require('a').mock;
original = mock();
mock.expect('testValue').expectAnything().whenCalled(onCalled).return('fake1');
function onCalled(arg,callback) {
//arg == 'testValue'
//callback == foo
}
function foo() {
}
original('testValue', foo); //returns 'fake1'
original('testValue',foo); //throws unexpected arguments
FAQs
Mocking framework
The npm package a receives a total of 2,588 weekly downloads. As such, a popularity was classified as popular.
We found that a demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.