smarter testing
This commit is contained in:
@@ -11,7 +11,9 @@ if list.closed_at
|
||||
=state 'list' list.state
|
||||
.display-row
|
||||
.display-label
|
||||
.display-field= button-close-list content=list
|
||||
.display-field
|
||||
= button-mark-list-helped content=list
|
||||
= button-close-list content=list
|
||||
.user-info-container
|
||||
each user in list.users
|
||||
=user.avatar_tag
|
||||
|
||||
@@ -112,7 +112,7 @@ header.top-menu
|
||||
.supplier-availability
|
||||
border: 2px solid #555
|
||||
border-radius: 4px
|
||||
padding: 5px 3px
|
||||
padding: 2px 5px
|
||||
font-weight: bold
|
||||
font-size: 0.9em
|
||||
float: right
|
||||
@@ -120,6 +120,6 @@ header.top-menu
|
||||
text-transform: uppercase
|
||||
margin-top: 10px
|
||||
&.currently-open
|
||||
color: #5f5
|
||||
color: #3c3
|
||||
&.currently-closed
|
||||
color: #f55
|
||||
|
||||
@@ -156,8 +156,7 @@ step "the supplier main board list total should be updated" do
|
||||
end
|
||||
|
||||
step "the supplier placed orders counter should be reduced" do
|
||||
sleep 0.8
|
||||
find('.supplier-orders-placed-count-number').text.should == "10"
|
||||
expect_that_eventually selector: '.supplier-orders-placed-count-number', has_text: "10"
|
||||
end
|
||||
|
||||
step "confirm the supplier close list modal" do
|
||||
|
||||
+1
-1
@@ -139,7 +139,7 @@ RSpec.configure do |config|
|
||||
|
||||
# Use color in STDOUT
|
||||
config.color = true
|
||||
config.fail_fast = true
|
||||
config.fail_fast = false
|
||||
|
||||
# Use color not only in STDOUT but also in pagers and files
|
||||
config.tty = true
|
||||
|
||||
@@ -27,6 +27,36 @@ module SpecEmberHelpers
|
||||
classes.should include class_name
|
||||
end
|
||||
|
||||
# expect_that_eventually selector: '.supplier-orders-placed-count-number', has_text: "10"
|
||||
def expect_that_eventually(options = {})
|
||||
selector = options[:selector] or raise "An argument selector: '.my-selector' is required"
|
||||
time = 0
|
||||
expected_value, value_method = case options
|
||||
when ->(h){ h.has_key? :has_text } then [options[:has_text], 'text()']
|
||||
when ->(h){ h.has_key? :has_value } then [options[:has_value], 'val()']
|
||||
else
|
||||
raise "No matcher can be found, possible matchers: :has_text, ..."
|
||||
end
|
||||
current_value = page.evaluate_script("$('#{selector}').#{value_method}")
|
||||
while current_value != expected_value and time < 30
|
||||
sleep 0.1
|
||||
current_value = page.evaluate_script("$('#{selector}').text()")
|
||||
time += 1
|
||||
end
|
||||
#current_value.should eq expected_text
|
||||
#if expected_text = options[:has_text]
|
||||
#current_value = page.evaluate_script("$('#{selector}').#{value_method}")
|
||||
#while current_text != expected_text and time < 30
|
||||
#sleep 0.1
|
||||
#current_text = page.evaluate_script("$('#{selector}').text()")
|
||||
#time += 1
|
||||
#end
|
||||
#current_text.should eq expected_text
|
||||
#else
|
||||
#raise "No matcher can be found, possible matchers: :has_text, ..."
|
||||
#end
|
||||
end
|
||||
|
||||
def js_set_field(selector, value)
|
||||
find selector
|
||||
page.execute_script("$('#{selector}').val('#{value}').trigger('change')")
|
||||
|
||||
Reference in New Issue
Block a user