panthomakos / timezone

Accurate current and historical timezones for Ruby with support for Geonames and Google latitude - longitude lookups.
http://rubygems.org/gems/timezone
MIT License
354 stars 49 forks source link

Stub Timezone for Rspec #96

Closed Shuiei closed 6 years ago

Shuiei commented 6 years ago

Hello,

I have found your gem really useful but I have an issue with it. It seems that I can't stub the HTTP calls made to google maps API from your gem.

I tried to put inside my rspec/support a file named timezone.rb and put inside ::Timezone::Lookup.config(:test). It seems the call is still made since WebMock raise me an error saying that no HTTP call is allowed.

Do you have any way to do it? Since I was not able to find any solution by reading your source code.

Thanks =D

panthomakos commented 6 years ago

Can you please provide the version of the gem that you are using; and a minimal reproducible example?

Are you sure the support file is being loaded and not overwritten by another timezone configuration block?

When you configure the test adapter this way, there is no possibility for a call to still be made to Google because the underlying adapter changes to an in memory implementation.

Shuiei commented 6 years ago

Ya have found the way to solve my problem. You was right I didn'nt set correctly the test configuration. I close this issue. Thanks for your help 👍

panthomakos commented 6 years ago

Glad you've worked it out!

gilbertjennic commented 2 years ago

Ya have found the way to solve my problem. You was right I didn'nt set correctly the test configuration. I close this issue. Thanks for your help 👍

Can you please explain how you got this issue resolved I am facing exactly the same issue ? Thanks in Advance.