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

Fix: Location services restart on receiving KCLErrorLocationUnknown #432

Closed cognitiveflux closed 9 years ago

cognitiveflux commented 9 years ago

Current BW::Location implementation only restarts immediate location services (not compass or significant change) on receiving a KCLErrorLocationUnknown error Updated to restart services based on the user provided options and method invocation (in the same way that services are stopped)

cognitiveflux commented 9 years ago

Admittedly I'm not the most experienced with rspec, tried adding the following but it reported 'MISSING - empty specification' for both. Also receiving NoMethodError for should_receive, any suggestions welcome:

it "should throw an error if location is unknown" do
  BW::Location.get do |result|
    result[:error].should == BW::Location::Error::LOCATION_UNKNOWN
  end

  error = NSError.errorWithDomain(KCLErrorDomain, code: KCLErrorLocationUnknown, userInfo: nil)
  BW::Location.locationManager(location_manager, didFailWithError: error)
end

it "should restart location services if it receives a LocationUnknown error" do
  BW::Location.get do |result|
    result[:error].should == BW::Location::Error::LOCATION_UNKNOWN
  end

  BW::Location.should_receive(:stop)
  BW::Location.should_receive(:start)
  error = NSError.errorWithDomain(KCLErrorDomain, code: KCLErrorLocationUnknown, userInfo: nil)
  BW::Location.locationManager(location_manager, didFailWithError: error)
end
otzy007 commented 9 years ago

:cry: It's still not working. Check this app. If you leave it running for 15 minutes on City Bicycle Ride in the simulator it will get error: 3 and crash. I've also merged both 432+422 and tested but I have the same result. Check this branch.

Before anyone would say :stuck_out_tongue_winking_eye: Yes, I did rake clean:all, reset the simulator, blah, blah, blah