Project

neverland

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Ever need to test geolocation in your Rails app? This gem makes it easy.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Neverland

Build Status

Neverland takes the pain out of testing HTML5 geolocation within your Rails app. For more on HTML5 geolocation, check out the spec.

Getting Started

To install, add the following to your Gemfile:

gem 'neverland'

In your test environment initializer, add the Neverland middleware:

Dummy::Application.configure do
  # ...

  config.middleware.use Neverland::Middleware
end

By default, Neverland will mock the result of navigator.geolocation.getCurrentLocation to latitude 42.31283, longitude -71.114287. This can be overridden by sending the parameters neverland[:latitude] and neverland[:longitude]. Error states can also be triggered by setting neverland[:error_code].

Caveats

  • The implementation naievely overrides the browser's geolocation implementation by inserting a JavaScript tag into the response.

  • The middleware will treat the response body as HTML. If you're using XHTML, this could cause issues.