Skip to content

Instantly share code, notes, and snippets.

@threewordphrase
Created September 11, 2016 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save threewordphrase/38bc77b097030870d2545dfff2361cb7 to your computer and use it in GitHub Desktop.
Save threewordphrase/38bc77b097030870d2545dfff2361cb7 to your computer and use it in GitHub Desktop.
module FeatureHelpers
def ng_visit(state_name, route_params={}, options={})
js_route_params = route_params.to_json
js_route_opts = {
reload: true
}.merge(options).to_json
inactive = (page.evaluate_script("typeof(angular)") == 'undefined')
visit '/' if inactive
js = "angular.element($('body[ng-app]')).injector().get('$state').go('#{state_name}', #{js_route_params}, #{js_route_opts});"
page.evaluate_script %{#{js}}
wait_until_angular_ready
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment