Skip to content
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

Add stub after launch #94

Open
shunmugarajrntbci opened this issue Feb 22, 2018 · 1 comment
Open

Add stub after launch #94

shunmugarajrntbci opened this issue Feb 22, 2018 · 1 comment
Labels

Comments

@shunmugarajrntbci
Copy link

Is it possible to add new stub after launch, after navigating few viewcontroller. I need to add new stub at 3rd screen replacing old stub

@kylef
Copy link
Owner

kylef commented Feb 22, 2018

Yes, you can add stubs whenever you like. The one limitation is that you need to ensure that the NSURLSessionConfiguration includes MockingjayProtocol when the NSURLSession instance is created.

If you are using the default session and would like the configuration swizzled to contain mockingjay's session (default behaviour when you run Mockingjay in tests). Then you can call mockingjaySwizzleDefaultSessionConfiguration upfront (during app launch or such, providing it is before you create any NSURLSession that will performing the requests):

URLSessionConfiguration.mockingjaySwizzleDefaultSessionConfiguration()

Alternatively, when creating NSURLSession, you can add MockingjayProtocol to the list of protocol classes at the front:

let configuration = URLSessionConfiguration.defaultSessionConfiguration()
configuration.protocolClasses = [MockingjayProtocol.self] as [AnyClass] + configuration.protocolClasses!

let session = URLSession(configuration: configuration)

let task = session.dataWithRequest(...)

@kylef kylef added the question label Feb 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants