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

“Client not configured” error #13

Closed
jnv opened this issue Mar 8, 2015 · 7 comments
Closed

“Client not configured” error #13

jnv opened this issue Mar 8, 2015 · 7 comments
Assignees
Labels

Comments

@jnv
Copy link
Contributor

jnv commented Mar 8, 2015

Somehow some specs are failing on top-level class which should delegate calls to a client instance: https://travis-ci.org/cvut/kosapi_client.rb/jobs/53568760

This is happening even with isolated classes like HttpClient – something is trying to call to_str on KOSapiClient. Frankly, I have no idea what's going on.

@jnv jnv added the bug label Mar 8, 2015
@jnv
Copy link
Contributor Author

jnv commented Mar 8, 2015

I see this is addressed in PR #10, but I wouldn't accept this hack.
It makes no sense that the code suddenly stopped working.

@DraCzris
Copy link

DraCzris commented Mar 8, 2015

IMHO it is related to rspec mocking (instance_doble). Because when I've tried to swap instance doubles with real object instances it works.

Maybe it is linked to mauricio/rspec-mocks@80c740e

@jnv
Copy link
Contributor Author

jnv commented Mar 8, 2015

Yep, it occured to me that it might be some metaprogramming mindfuck caused by the fact that KOSapiClient module acts both as a namespace and a delegator for a client.

@DraCzris
Copy link

DraCzris commented Mar 8, 2015

In this exact situation, that is not caused by metaprogramming. The problem here is that the mocking service is invoking to_str method. Thats problem of rspec as in rspec/rspec-mocks#577.

I've come around with a solution, which is less "hackier" in 9cb112f of #10

@jnv
Copy link
Contributor Author

jnv commented Mar 8, 2015

Well, look at the date of that PR, this behaviour has been fixed in RSpec 3.0. Since we don't have a Gemfile.lock file, I guess this is some regression in newer RSpec (I run this on 3.2).

So the solutions are:

  • Lock rspec-mocks dev dependency to an earlier version (in gemspec),
  • introduce a workaround into the top-level module (which is fundamentally wrong because the module cannot be coerced into an equivalent string representation),
  • remove implicit forwarding behaviour from the top-level module – I personally favour this option, because it removes complexity and nudges to a better practice (at a very slight price of inconvenience), however it is a breaking change.

@tszolar
Copy link
Member

tszolar commented Mar 27, 2015

In 0439b5b I have refactored client lazy initalization to be more robust. Before this change an error was thrown right away when the client was initialized without supplying API credentials. Now the client only throws an error when an API request is made without credentials.

It should fix this issue in a clean way and it also prevents other possible problems in the future.

@tszolar tszolar closed this as completed Mar 27, 2015
@jnv
Copy link
Contributor Author

jnv commented Mar 27, 2015

👍 Nice job, this is definitely an improvement though I'm still not a fan of the top-level stateful singleton KOSapiClient delegator.

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

3 participants