Can I use a custom matcher with sinon.assert.calledWith? - sinon

Sinon asserts are better when trying to check if a function was correctly called with arguments because it will tell you what part of the argument failed.
That said, I'm having trouble to get it to work with a custom matcher. The docs says that sinon.assert.calledWithMatch is the same as sinon.assert.calledWith(spy, sinon.match(args)), which led me to believe I could do
sinon.assert.calledWith(spy, sinon.match(args => args.foo = 'bar'))
But it seems that is not the case.
Am I doing something wrong?

Related

Eslint complaining about hyphens in variable name

So I have to use a specific variable name (g-recaptcha-response) in my form post in order to pass a captcha process using google recaptcha V2. The thing is eslint will always complaint about the variable name wit the error "Parsing error: Const declarations require an initialization value". I know the problem it's because of the hyphenated name convention but I can't find anywhere the way to bypass this rule and I have to use that name since it's a re-captcha parameter that needs to be send with the form.
const g-recaptcha-response = await this.$recaptcha.getResponse(),
I need to make something like that work within an eslint /& vue-3 template with composition API, any feedback will be really appreciated.

Error messages: result.rejectvalue 3rd argument

in the following code what is the point of the third argument to rejectValue ?
errors.rejectValue("descriptions", "second_lang_desc_required", new String[] { secondLang.getCode() }, null );
I have this in the message value : Description in second language of application required {0} but this is exactly waht I see in the JSP, no replacement
According to Spring doc the purpose of the third argument is to provide a string array of arguments for replacing vars in messages.
In other words and telling from your code example its exactly what you expected it to be.
I guess you already checked if secondLang.getCode() is different from null. If so please have a look at whether or not you are using the latest release of org.springframework.
It is working in 4.2.4 but I remember having had to use a workaround before switching to 4.2.4 (Yes, of course - a clever guy would check change history and would 'know' instead of assuming, but I never claimed to be one, did I?)

Router.after is deprecated, is there a replacement global after hook?

I want to change the title of the page after any route has been rendered, to the name of that route. This is the code I was using before:
Router.after(function(){document.title = this.route.name;});
The manual mentions using onAfterAction inside an individual route, but I'd like to do it globally?
You must have missed this : http://eventedmind.github.io/iron-router/#using-hooks
The correct syntax is straightforward :
Router.onAfterAction(function(){
// your hook definition
});
Note : The guide is for iron:router#1.0.0-pre2 which must be added to your app explicitly like this :
meteor add iron:router#1.0.0-pre2
But the Router.onAfterAction works fine in iron:router#0.9.X too.
I suggest using this.route.getName() instead of this.route.name, see more about this issue here :
https://github.com/EventedMind/iron-router/issues/878
The router.after(); method although has been deprecated will still be allowed in the code in terms of syntax. As discussed in the IRC chat the best approach is to use the new syntax.
Router.onAfterAction(function(){
document.title = this.route.name;
});
This should resolve what you are looking for.
Cheers !
Ryan

Error while compiling botan sample example in Qt

I am trying to find out the error for two days but still haven't got this unknown reason figure out.
I have configured and compiled Botan library. Everything goes ok but when try to write this sample code to be run..
S2K* s2k = get_s2k("PBKDF2(SHA-256)");
s2k->set_iterations(4049);
SecureVector<byte> key_and_IV = s2k->derive_key(48, passphrase).bits_of();
SymmetricKey key(key_and_IV, 32);
it says error: 'class Botan::PBKDF' has no member named 'set_iterations'
How can I solve this problem ?
The Botan docs for v1.11.1 report that the function get_s2k() has been deprecated, recommending that you use get_pbkdf() instead.
According to the docs, get_sdk(algospec) just returns the result of a call to get_pbkdf(algo_spec) which will give you a pointer to an instance of the class Botan::PBKDF.
First things first then, your code needs to be something more like:
PBKDF *s2k = getpbkdf("PBKDF2(SHA-256)");
Unfortunately without knowing what you want to do with s2k I can't help any further, as the docs have no reference to a public member function of PBKDF called set_iterations(). You're getting the error you mention because Botan::PBKDF really does have no member named set_iterations. You need to read the docs, work out what the purpose of set_iterations() was in your now deprecated example and hence how to achieve that purpose in the newer version of the library.
Possibly you missed your library header... as your error message says: 'has no member named...'

symfony2 console arguments

I want to create a single named argument/option for symfony command. And want symfony to distinguish those 3 options:
my:command, which means something like my:command --arg=null
my:command --arg, which means my:command --arg=defalutValue
my:command --arg=someValue, which is fully explicit.
I.e. I want two working modes for code under that command: default one and non-default with additional argument, and that arg should have default value.
I understand, that I could create 2 args, but I'm looking for one-arg-to-rule-them-all solution.
Is it possible to accomplish that with built-in classes or should I create custom ones? If solution is only available with custom classes, please tell me, where to start (i.e. "create subclass of ..." or "install a bundle named ..."), cause I'm not familiar with Symfony2's architecture.
It is possible:
->addOption('arg', 'a', InputOption::VALUE_NONE)
my:command => $input->getOption('arg') //false
my:command --arg => $input->getOption('arg') //true
my:command --arg=5 => $input->getOption('arg') //5
Answer by corvax is incorrect and doesn't work. As of today, you just cannot achieve this.
It is even stated in the Console documentation: Using Command Options.
See also these issues on GitHub:
#8135 [Console] Input options with InputOption::VALUE_OPTIONAL and InputOption::VALUE_NONE not working as expected
#11883 [Console] Added three state long option
#12769 [Console] Ability to use option default only if the option was passed
#12773 [Console] Add method to know parsed option
Symfony2 have console component which can be used separately. You can see documentation here. For more example you can check implementations of SensioGeneratorBundle.

Resources