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

Injection question #3

Open
alekseyig opened this issue Mar 21, 2014 · 2 comments
Open

Injection question #3

alekseyig opened this issue Mar 21, 2014 · 2 comments

Comments

@alekseyig
Copy link

Hello,
In your UserServiceSpec test class you inject mock[UserRepository] by overriding userRepository in components.Default as "override val userRepository = mock[UserRepository]". Then you call, for example, "users.getById(anyLong)" which in turn will use mocked userRepository.
I was wondering if there is a way to not to call "users.getById(anyLong)" directly, but do the calls the same way you did in UserRouteSpec or LandingRouteSpec using WitApp approach and "route(header).get" calls and still being able to inject the mock implementation of the components.

Thank you.

@kaeawc
Copy link
Owner

kaeawc commented May 28, 2014

I missed this issue / question before. In order to mock the service and database layers and essentially unit testing the controller this would require the controller layer to do depend on some setting in application.conf. Now that I've done some refactoring to the project this should actually be pretty easy.

@alekseyig
Copy link
Author

Are you going to provide the example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants