Trying to use getArgumentAtIndexAsObject from NSInvocation+OCMAdditions.h - ios8

maybe it's a silly thing... I'm trying to use
- (id)getArgumentAtIndexAsObject:(NSInteger)argIndex;
From NSInvocation+OCMAdditions.h, but I can't import the Category and if try to use the method is not available.
I'm using cocoaPods to get OCMock and I imported the header class:
#import <OCMock/OCMock.h>
maybe is a setting in cocoaPods?
Any help is appreciated.
Thanks

Finally as Erick said is not possible to use that method, so I used this way:
//We mock the methods loginWithUser
[[[controllerMocked stub] andDo:^(NSInvocation *invocation) {
void (^sucessBlock)(NSString *token);
[invocation getArgument:&sucessBlock atIndex:4];
sucessBlock(#"1234567890");
}] loginWithUser:[OCMArg any] andPassword:[OCMArg any] withSuccess:[OCMArg any] withFailure:[OCMArg any]];
However the right answer is the Erick one :)

This is a private method intended to be used by OCMock internally. It is not exported as part of the pod.
The reason is that I'm trying to keep the public API of OCMock, which must be supported for a long time, as small as possible.
If you want to use getArgumentAtIndexAsObject: in your project do so by adding the corresponding header file to your project. However, there is no guarantee that the method will be available in future versions of OCMock.

Related

How does Swagger document NestJS Reusable Enums?

Does anyone have an easy way to document reusable enums in nestjs using swagger? I don't mean showing them as options in a request. I am looking to document the enums themselves, since they are not very understandable on their own:
export enum ScanState {
SCAN_WAITING_FOR_CAPTURE_DATA = 'SCAN_WAITING_FOR_CAPTURE_DATA',
SCAN_VALIDATING_CAPTURE_DATA = 'SCAN_VALIDATING_CAPTURE_DATA',
SCAN_CAPTURE_DATA_VALID = 'SCAN_CAPTURE_DATA_VALID',
SCAN_CAPTURE_DATA_INVALID = 'SCAN_CAPTURE_DATA_INVALID',
}
I would think there would be some kind of #Schema or #ApiAdditionalProperty or something I could just add to the top of the enum for documentation, which would then be added to the Schemas portion of the Swagger docs similar to how it already works with classes. I'm using #nestjs/swagger version 6.0.4.
Seems to be a classic Swagger/NestJS problem, but I haven't been able to find a good solution elsewhere. Thank you, any help is greatly appreciated!

Hint or infer the return type for RSpec let() implementing FactoryGirl create()

Using RubyMine, in an rspec test, is there a way to let RubyMine know the type of the created object (for auto-completion and 'cannot find ' warning suppression?
eg:
# #yieldreturn [Tibbees::Tibbee]
let!(:tibbee) {
create(:tibbee,
canonical_vendible: article_vendible,
owner: tibbee_user)
}
RubyMine doesn't seem to recognise #yieldreturn (and I'm not sure if that's correct anyhow) and I've had no luck with #type and #return.
The
let!(:tibbee) { create(...) || Tibbees::Tibbee.new }
cludge works, but yuk. Any advice greatly appreciated. Perhaps there's even a way to let the factories take care of it, but that seems 'too deep' an abstraction to be likely to be picked up by RubyMine?
Not an immediate solution, but:
While google on this, I came across https://github.com/JetBrains/ruby-type-inference which holds great promise for the future, that is probably relevant to anyone with an interest in this question.
From the README:
ruby-type-inference project is a completely new approach to tackle the problems Ruby dynamic nature by providing more reliable symbol resolution and type inference.
In answer to some questions I asked them:
We are going to make the plugin working and publicly available with 2017.3 release though it will definitely be in "beta" since several problems are yet to be solved even on the theoretical side. For everything to work real properly we have to rework our type system on IDE side which is most likely not going to be completed in 2017.
It might be run at the moment, however ... the results are more of experimental value ... [and] it will be difficult to use it on a daily basis.
This is an old request, but updating for future reference with discussion at https://youtrack.jetbrains.com/issue/RUBY-19907:
As of today (RubyMine 2021.2.3, Build #RM-212.5457.52) Rubymine can now introspect the correct type for FactoryBot create within a let, so that:
let(:name) { create(:some_model)} now has the type inferred correct from the factory.
However it would still be useful to be able to annotate a let that can't be introspected (maybe it's not calling FactoryBot).
But the suggestion of #yieldreturn seems wrong - that's for methods that take a block. But it would be nice if you could annotate let(:whatever){} with #return tag. Compare https://rubydoc.info/gems/yard/file/docs/Tags.md#yieldreturn with https://rubydoc.info/gems/yard/file/docs/Tags.md#return

How to know the interfaces or methods if I don't know the name of them in Java?

If I don't know there exists an interface or method in Java and I have to write one by my own.
How can I avoid this? (It takes much more time to write a method by myself.) How can I find a method which I even don't know the name of it?
Q: Are you worried that you might create an interface or method with a duplicate name?
If so, the answer is to use "packages"
EXAMPLE:
package com.mypackage;
interface myInterface {
public void myMethod ();
}
Here is a good tutorial:
http://docs.oracle.com/javase/tutorial/java/package/packages.html

Get names of structs that implement an interface or inherit a struct

Is it possible to get a slice of strings that represent the names of all types that implement an interface or inherit from a specific struct in a specific package using reflection?
After some research on the reflect package's doc, I don't think it's possible. That's not the way reflection work in go: the interfaces mechanism not beeing declarative (but duck-typed instead), there is no such list of types.
That said, you may have more luck using the ast package to parse your project, get the list of types, and check wheter or not they implement an interface, then write some code to give you the said slice. That would add a step to compilation, but could work like a charm.
AFAIK, you can't do this with reflect, since packages are kinda out of reflect's scope.
You can do this the same way godoc's static analysis works. That is, using code.google.com/p/go.tools/go/types to parse the package's source code and get the type info.
The go oracle can do this. https://godoc.org/code.google.com/p/go.tools/oracle
Here is the relevant section of the user manual.

An alternative to TaskEx.FromResult on a platform where it's not available

I am converting a portable class library to use a different profile (78). Most of the changes were related to reflection API, and now I have few last lines that don't compile, all of them are using TaskEx.FromResult.
TaskEx.FromResult is handy when a method returns Task, and a value of T needs to be wrapped and returned from the method, e.g.:
public Task<int> ReturnTaskOfInt()
{
return TaskEx.FromResult(42);
}
Unfortunately TaskEx is not available for some PCL profiles. Perhaps it shouldn't be hard to write a replacement for it, and I will appreciate an advise.
Oops, it was damn easy. TaskEx.FromResult is not available, but Task.FromResult is there.

Resources