Skip to content
Extraits de code Groupes Projets
Valider 1c7e5b70 rédigé par Jonne Haß's avatar Jonne Haß
Parcourir les fichiers

Improve apend_to_publisher

- Use custom matcher that polls #value of the element
- Wait for the text field to become visible before entering text
parent 7e4504ed
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
RSpec::Matchers.define :have_path do |expected| RSpec::Matchers.define :have_path do |expected|
match do |actual| match do |actual|
start_time = Time.now await_condition { actual.current_path == expected }
until actual.current_path == expected
return false if (Time.now-start_time) > Capybara.default_wait_time
sleep 0.05
end
true
end end
failure_message_for_should do |actual| failure_message_for_should do |actual|
...@@ -15,3 +10,27 @@ RSpec::Matchers.define :have_path do |expected| ...@@ -15,3 +10,27 @@ RSpec::Matchers.define :have_path do |expected|
"expected #{actual.inspect} to not have path #{expected.inspect} but it had" "expected #{actual.inspect} to not have path #{expected.inspect} but it had"
end end
end end
RSpec::Matchers.define :have_value do |expected|
match do |actual|
await_condition { actual.value && actual.value.include?(expected) }
end
failure_message_for_should do |actual|
"expected #{actual.inspect} to have value #{expected.inspect} but was #{actual.value.inspect}"
end
failure_message_for_should_not do |actual|
"expected #{actual.inspect} to not have value #{expected.inspect} but it had"
end
end
def await_condition &condition
start_time = Time.now
until condition.call
return false if (Time.now-start_time) > Capybara.default_wait_time
sleep 0.05
end
true
end
...@@ -4,11 +4,11 @@ module PublishingCukeHelpers ...@@ -4,11 +4,11 @@ module PublishingCukeHelpers
end end
def append_to_publisher(txt, input_selector='#status_message_fake_text') def append_to_publisher(txt, input_selector='#status_message_fake_text')
elem = find(input_selector, visible: false) elem = find(input_selector)
elem.native.send_keys(' ' + txt) elem.native.send_keys(' ' + txt)
# make sure the other text field got the new contents # make sure the other text field got the new contents
expect(page).to have_xpath("//input|textarea/.[@id='status_message_text' and contains(@value, '#{txt}')]", visible: false) expect(find("#status_message_text", visible: false)).to have_value txt
end end
def upload_file_with_publisher(path) def upload_file_with_publisher(path)
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter