Green specs for ember 1.13

This commit is contained in:
2015-08-13 15:08:04 +02:00
parent 8ce95f72e9
commit 0415603a49
7 changed files with 21 additions and 10 deletions
@@ -16,6 +16,7 @@ Feature: Sign up as user using facebook
Given there is a confirmed and open supplier
And there is a facebook user
And the user has an active order
And there is no user information stored in the local storage
#When I visit the user obtain token path
When the user is on the homepage
Then the user is redirected to the sign in page
@@ -38,6 +39,7 @@ Feature: Sign up as user using facebook
Given there is a confirmed and open supplier
And there is a instagram user
And the user has an active order
And there is no user information stored in the local storage
#When I visit the user obtain token path
When the user is on the homepage
Then the user is redirected to the sign in page
@@ -30,8 +30,7 @@ step "the section table should not be marked as in need of help" do
end
step 'the table should be marked as occupied and having an active order' do
classes = find(".section-table-#{@table.id}")['class'].split(/\s+/)
expect(classes & %w[occupied active_order]).to eq %w[occupied active_order]
assert_element_class ".section-table-#{@table.id}", %w[occupied active_order]
end
step "I click on section table as a supplier" do
+6 -5
View File
@@ -15,16 +15,17 @@ module SpecEmberHelpers
JSON.parse(h)
end
def assert_element_class(selector, class_name)
def assert_element_class(selector, expected_class_names)
find selector # capybara wait for element
time = 0
classes = page.evaluate_script("$('#{selector}').attr('class')")
while !classes.include?(class_name) and time < 10
expected_class_names = Array.wrap(expected_class_names).sort
found_classes = page.evaluate_script("$('#{selector}').attr('class')").to_s.split(/\s+/).sort
while (found_classes & expected_class_names) != expected_class_names and time < 10
sleep 0.1
classes = page.evaluate_script("$('#{selector}').attr('class')")
found_classes = page.evaluate_script("$('#{selector}').attr('class')").to_s.split(/\s+/).sort
time += 1
end
classes.should include class_name
(found_classes & expected_class_names).sort.should eq expected_class_names
end
# expect_that_eventually selector: '.supplier-orders-placed-count-number', has_text: "10"