Created
September 11, 2016 23:24
-
-
Save threewordphrase/38bc77b097030870d2545dfff2361cb7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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