Make ember route expectations smarter
This commit is contained in:
@@ -38,6 +38,7 @@ Feature: Ordering a product as a user
|
|||||||
Then the user should see an empty active order panel
|
Then the user should see an empty active order panel
|
||||||
And the user clicks on the order 'Heineken beer' twice
|
And the user clicks on the order 'Heineken beer' twice
|
||||||
And the user clicks on the user order button
|
And the user clicks on the user order button
|
||||||
|
And I wait 1 second
|
||||||
Then an order with 2 products 'Heineken beer' should have been created
|
Then an order with 2 products 'Heineken beer' should have been created
|
||||||
And no order for the product 'Apple pie' should have been created
|
And no order for the product 'Apple pie' should have been created
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ end
|
|||||||
|
|
||||||
step "the user should be redirected to the archived list path" do
|
step "the user should be redirected to the archived list path" do
|
||||||
#route_should_be 'user#history_list'
|
#route_should_be 'user#history_list'
|
||||||
sleep 1
|
|
||||||
ember_route_should_be "/lists/#{@order.list_id}"
|
ember_route_should_be "/lists/#{@order.list_id}"
|
||||||
page.should have_selector ".order-row-#{@order.id}"
|
page.should have_selector ".order-row-#{@order.id}"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -27,5 +27,5 @@ end
|
|||||||
## ASSERTIONS
|
## ASSERTIONS
|
||||||
|
|
||||||
step "the supplier should be redirected to the root path" do
|
step "the supplier should be redirected to the root path" do
|
||||||
ember_route.should == '/'
|
ember_route_should_be '/'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ end
|
|||||||
|
|
||||||
step "the supplier should be redirected to the supplier settings path" do
|
step "the supplier should be redirected to the supplier settings path" do
|
||||||
# route_should_be 'supplier#edit'
|
# route_should_be 'supplier#edit'
|
||||||
ember_route.should == '/settings'
|
ember_route_should_be '/settings'
|
||||||
end
|
end
|
||||||
|
|
||||||
step "the supplier email is the new email and the unconfirmed email is empty" do
|
step "the supplier email is the new email and the unconfirmed email is empty" do
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ end
|
|||||||
|
|
||||||
step "the user clicks on the user order button" do
|
step "the user clicks on the user order button" do
|
||||||
find('.order-selected-products-button').click
|
find('.order-selected-products-button').click
|
||||||
sleep 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
step "the user has an active order" do
|
step "the user has an active order" do
|
||||||
|
|||||||
@@ -15,13 +15,26 @@ module SpecRouteHelpers
|
|||||||
end
|
end
|
||||||
|
|
||||||
def ember_route_should_be(route_def)
|
def ember_route_should_be(route_def)
|
||||||
ember_route.should == route_def
|
max_wait = 4
|
||||||
|
time = 0.0
|
||||||
|
time_step = 0.25
|
||||||
|
while time < max_wait && ember_route != route_def
|
||||||
|
time += time_step
|
||||||
|
sleep time_step
|
||||||
|
end
|
||||||
|
ember_route(omit_should_raise: true).should == route_def
|
||||||
end
|
end
|
||||||
|
|
||||||
def ember_route
|
def ember_route(omit_should_raise: nil)
|
||||||
# currentRouteName does not include model information: /list/123 => currentRouteName == 'list'
|
# 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('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__.lookup('router:main').location.lastSetURL| # not working for direct path supplier#/settings
|
||||||
page.evaluate_script %{App.__container__ && (window.location.hash || "#/").substr(1)}
|
route = page.evaluate_script %{App.__container__ && (window.location.hash || "#/").substr(1)}
|
||||||
|
unless omit_should_raise
|
||||||
|
def route.should(*)
|
||||||
|
raise "Cannot call should on ember route. Use ember_route_should_be instead"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
route
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user