Files
mozo-backend/spec/support/route_helpers.rb
T

28 lines
1.0 KiB
Ruby

module SpecRouteHelpers
# allows tests like:
# route_should_be 'agama_groups#index'
def route_should_be(route_def, options = {})
route_hash = case route_def
when String
controller_name, action_name = route_def.split('#')
#action_name = 'index' unless action_name.present?
{controller: controller_name, action: action_name}
else
route_def
end
route_hash.merge! options
Rails.application.routes.recognize_path(page.current_path).should include route_hash
end
def ember_route_should_be(route_def)
ember_route.should == route_def
end
def ember_route
# currentRouteName does not include model information: /list/123 => currentRouteName == 'list'
# page.evaluate_script %|App.__container__.lookup('controller:application').get('currentRouteName')|
# page.evaluate_script %|App.__container__.lookup('router:main').location.lastSetURL| # not working for direct path supplier#/settings
page.evaluate_script %{App.__container__ && (window.location.hash || "#/").substr(1)}
end
end