rubymotion-community / BubbleWrap

Cocoa wrappers and helpers for RubyMotion (Ruby for iOS and OS X) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull requests
Other
1.18k stars 208 forks source link

Location.* methods not calling return block when testing #388

Closed jonmorehouse closed 10 years ago

jonmorehouse commented 10 years ago

I'm new to BubbleWrap so excuse me if this is the expected action, but for some reason none of my return blocks are called when using the Location wrap. Am I missing something or is this a bug in my code or possibly the library?

markrickert commented 10 years ago

Can you post the code you're using? I'm using the location wrapper in lots of my projects and don't have any issues.

clayallsopp commented 10 years ago

Additionally, are you testing on a device or the simulator?

jonmorehouse commented 10 years ago

Hmm, it looks like I figured out at least part of the issue. I needed to go to simulator and grant access to location services. Once I did that I was able to successfully get the location data as neede

jonmorehouse commented 10 years ago

However, this still doesn't entirely solve my problem, as I'm trying to write a spec to make sure the code I'm writing works. How would I go about that?

clayallsopp commented 10 years ago

If you uninstall and re-install your app, can you confirm that the location permission request popup appears? I just double-checked with our location sample and it worked for me

The way I'd suggest testing location is to use some sort of mock location manager, or mock methods on CLLocationManager itself. Check out our location spec: https://github.com/rubymotion/BubbleWrap/blob/master/spec/motion/location/location_spec.rb

(the location manager is also stored as a module ivar, which could be another vector for testing)

jonmorehouse commented 10 years ago

Awesome, this is exactly what I need. I'll implement a mock location suite instead, once I know its working.