SlideShare a Scribd company logo
async makes your
tests fun
Michael Reinsch

michael@movingfast.io

github / twitter: mreinsch
capybara acceptance
testing
scenario "publish event" do
visit event_url(event)
click_on "Publish Event"
expect(event.reload).to be_published
end
scenario "publish event", js: true do
visit event_url(event)
click_on "Publish Event"
expect(event.reload).to be_published
end
scenario "publish event", js: true do
visit event_url(event)
click_on "Publish Event"
expect(event.reload).to be_published
end
scenario "publish event", js: true do
visit event_url(event)
click_on "Publish Event"
expect(event.reload).to be_published
end
Failure/Error: expect(event.reload).to be_published
rspec
process
rspec
process
rails server
process
spawns
rspec
process
rails server
process
spawns
browser
process
spawns /
sends
commands
rspec
process
rails server
process
spawns
browser
process
spawns /
sends
commands
http requests
scenario "publish event", js: true do
visit event_url(event)
click_on "Publish Event"
expect(page).to have_content("Registration: Open")
expect(event.reload).to be_published
end
scenario "publish event", js: true do
visit event_url(event)
click_on "Publish Event"
expect(page).to have_content("Registration: Open")
expect(event.reload).to be_published
end
scenario "publish event", js: true do
visit event_url(event)
click_on "Publish Event"
expect(page).to have_content("Registration: Open")
expect(event.reload).to be_published
end
Failure/Error: Unable to find matching line from backtrace
ActiveRecord::StatementInvalid:
PG::TRDeadlockDetected: ERROR: deadlock detected
DETAIL: Process 7186 waits for AccessShareLock on relation 16570 of
database 16396; blocked by process 7274.
Process 7274 waits for AccessExclusiveLock on relation 17012 of database
16396; blocked by process 7186.
ajax
vs.
database_cleaner
# in spec/spec_helper.rb
config.append_after(:each) do
Rails.logger.debug("======= cleaning DB")
DatabaseCleaner.clean
end
module RSpecLoggerListener
extend self
def start(notification)
Rails.logger.info("nn====== Starting new test run")
end
def stop(notification)
Rails.logger.info("nn====== Test run finished")
end
def example_started(notification)
Rails.logger.info("nn====== START #{notification.example.full_description}")
end
def example_passed(notification)
Rails.logger.info("====== PASSED #{notification.example.full_description}")
end
def example_failed(notification)
Rails.logger.info("====== FAILED #{notification.example.full_description}")
end
def example_pending(notification)
Rails.logger.info("====== PENDING #{notification.example.full_description}")
end
end
RSpec.configuration.reporter.register_listener(
RSpecLoggerListener,
:start, :stop, :example_started, :example_passed,
:example_failed, :example_pending)
get it from: https://gist.github.com/mreinsch/2c8dbb01e51c32c3c5c8
module CapybaraHelperMethods
def wait_for_ajax
counter = 0
while !finished_all_ajax_requests?
counter += 1
sleep 0.2
raise "AJAX request took too long." if counter >= (Capybara.default_wait_time * 5)
end
end
def finished_all_ajax_requests?
active = page.evaluate_script <<-SCRIPT.strip.gsub(/s+/,' ')
(function () {
if (typeof jQuery != 'undefined') {
return jQuery.active;
}
else {
console.error("jQuery was undefined on " + document.URL + " - will retry...");
return -1;
}
})()
SCRIPT
active && active.zero?
end
end
RSpec.configuration.include CapybaraHelperMethods, :type => :feature
based on https://coderwall.com/p/aklybw/wait-for-ajax-with-capybara-2-0
scenario "publish event", js: true do
visit event_url(event)
click_on "Publish Event"
expect(page).to have_content("Registration: Open")
expect(event.reload).to be_published
wait_for_ajax
end
Beware of the async!
Michael Reinsch

michael@movingfast.io

github / twitter: mreinsch

More Related Content

What's hot

Deploying a Chef Server
Deploying a Chef ServerDeploying a Chef Server
Deploying a Chef Server
Hart Hoover
 
Service workers
Service workersService workers
Service workers
jungkees
 
Asynchronous and event-driven Grails applications
Asynchronous and event-driven Grails applicationsAsynchronous and event-driven Grails applications
Asynchronous and event-driven Grails applications
Alvaro Sanchez-Mariscal
 
Zero Downtime Deployment in Microservices era
Zero Downtime Deployment in Microservices eraZero Downtime Deployment in Microservices era
Zero Downtime Deployment in Microservices era
Alex Soto
 
1. Quick sartup a jenkins server on OpenShift
1. Quick sartup a jenkins server on OpenShift1. Quick sartup a jenkins server on OpenShift
1. Quick sartup a jenkins server on OpenShift
Huang Bruce
 
Test Failed, Then...
Test Failed, Then...Test Failed, Then...
Test Failed, Then...
Toru Furukawa
 
Service Worker Presentation
Service Worker PresentationService Worker Presentation
Service Worker PresentationKyle Dorman
 
Activation limit&flowlimit&maxjobs
Activation limit&flowlimit&maxjobsActivation limit&flowlimit&maxjobs
Activation limit&flowlimit&maxjobs
Nirmala Devi
 
Cookbook Reusability @ Chef Community summit 2014
Cookbook Reusability @ Chef Community summit 2014Cookbook Reusability @ Chef Community summit 2014
Cookbook Reusability @ Chef Community summit 2014
Sean OMeara
 
Stop js-1999
Stop js-1999Stop js-1999
Stop js-1999
Hunter Loftis
 
Service workers
Service workersService workers
Service workers
Pavel Zhytko
 
[1C1]Service Workers
[1C1]Service Workers[1C1]Service Workers
[1C1]Service Workers
NAVER D2
 
ChefConf 2016 - Writing Compossible Community Cookbooks using Chef Custom Res...
ChefConf 2016 - Writing Compossible Community Cookbooks using Chef Custom Res...ChefConf 2016 - Writing Compossible Community Cookbooks using Chef Custom Res...
ChefConf 2016 - Writing Compossible Community Cookbooks using Chef Custom Res...
Tim Smith
 
Service worker API
Service worker APIService worker API
Service worker API
Giorgio Natili
 
Service worker: discover the next web game changer
Service worker: discover the next web game changerService worker: discover the next web game changer
Service worker: discover the next web game changer
Sandro Paganotti
 
Secure your Web Application With The New Python Audit Hooks
Secure your Web Application With The New Python Audit HooksSecure your Web Application With The New Python Audit Hooks
Secure your Web Application With The New Python Audit Hooks
Nicolas Vivet
 
PWA 應用 - 實現網站離線瀏覽
PWA 應用 - 實現網站離線瀏覽PWA 應用 - 實現網站離線瀏覽
PWA 應用 - 實現網站離線瀏覽
Anna Su
 
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Patrick McDonnell
 
Refactoring a web application with Python
Refactoring a web application with PythonRefactoring a web application with Python
Refactoring a web application with Python
Cristian Gonzalez Sanchez
 
Ultimate Node.js countdown: the coolest Application Express examples
Ultimate Node.js countdown: the coolest Application Express examplesUltimate Node.js countdown: the coolest Application Express examples
Ultimate Node.js countdown: the coolest Application Express examples
Alan Arentsen
 

What's hot (20)

Deploying a Chef Server
Deploying a Chef ServerDeploying a Chef Server
Deploying a Chef Server
 
Service workers
Service workersService workers
Service workers
 
Asynchronous and event-driven Grails applications
Asynchronous and event-driven Grails applicationsAsynchronous and event-driven Grails applications
Asynchronous and event-driven Grails applications
 
Zero Downtime Deployment in Microservices era
Zero Downtime Deployment in Microservices eraZero Downtime Deployment in Microservices era
Zero Downtime Deployment in Microservices era
 
1. Quick sartup a jenkins server on OpenShift
1. Quick sartup a jenkins server on OpenShift1. Quick sartup a jenkins server on OpenShift
1. Quick sartup a jenkins server on OpenShift
 
Test Failed, Then...
Test Failed, Then...Test Failed, Then...
Test Failed, Then...
 
Service Worker Presentation
Service Worker PresentationService Worker Presentation
Service Worker Presentation
 
Activation limit&flowlimit&maxjobs
Activation limit&flowlimit&maxjobsActivation limit&flowlimit&maxjobs
Activation limit&flowlimit&maxjobs
 
Cookbook Reusability @ Chef Community summit 2014
Cookbook Reusability @ Chef Community summit 2014Cookbook Reusability @ Chef Community summit 2014
Cookbook Reusability @ Chef Community summit 2014
 
Stop js-1999
Stop js-1999Stop js-1999
Stop js-1999
 
Service workers
Service workersService workers
Service workers
 
[1C1]Service Workers
[1C1]Service Workers[1C1]Service Workers
[1C1]Service Workers
 
ChefConf 2016 - Writing Compossible Community Cookbooks using Chef Custom Res...
ChefConf 2016 - Writing Compossible Community Cookbooks using Chef Custom Res...ChefConf 2016 - Writing Compossible Community Cookbooks using Chef Custom Res...
ChefConf 2016 - Writing Compossible Community Cookbooks using Chef Custom Res...
 
Service worker API
Service worker APIService worker API
Service worker API
 
Service worker: discover the next web game changer
Service worker: discover the next web game changerService worker: discover the next web game changer
Service worker: discover the next web game changer
 
Secure your Web Application With The New Python Audit Hooks
Secure your Web Application With The New Python Audit HooksSecure your Web Application With The New Python Audit Hooks
Secure your Web Application With The New Python Audit Hooks
 
PWA 應用 - 實現網站離線瀏覽
PWA 應用 - 實現網站離線瀏覽PWA 應用 - 實現網站離線瀏覽
PWA 應用 - 實現網站離線瀏覽
 
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
 
Refactoring a web application with Python
Refactoring a web application with PythonRefactoring a web application with Python
Refactoring a web application with Python
 
Ultimate Node.js countdown: the coolest Application Express examples
Ultimate Node.js countdown: the coolest Application Express examplesUltimate Node.js countdown: the coolest Application Express examples
Ultimate Node.js countdown: the coolest Application Express examples
 

Viewers also liked

Ireland and Society, Lecture Three: Culture of Everyday Life
Ireland and Society, Lecture Three: Culture of Everyday LifeIreland and Society, Lecture Three: Culture of Everyday Life
Ireland and Society, Lecture Three: Culture of Everyday Life
Conor McCabe
 
Presentación12
Presentación12Presentación12
Presentación12
Ricardo Bastidas
 
Ireland and Society, Lecture One: Religion
Ireland and Society, Lecture One:  ReligionIreland and Society, Lecture One:  Religion
Ireland and Society, Lecture One: Religion
Conor McCabe
 
Presentación1
Presentación1Presentación1
Presentación1
Ricardo Bastidas
 
Jordan Michael Shaver's Resumé
Jordan Michael Shaver's Resumé Jordan Michael Shaver's Resumé
Jordan Michael Shaver's Resumé Jordan Shaver
 
11.05.2016 r. wyniki Lokum Deweloper I kw. 2016 r.
11.05.2016 r. wyniki Lokum Deweloper I kw. 2016 r.11.05.2016 r. wyniki Lokum Deweloper I kw. 2016 r.
11.05.2016 r. wyniki Lokum Deweloper I kw. 2016 r.
LokumDeweloper
 
Finding the right stuff, an intro to Elasticsearch with Ruby/Rails
Finding the right stuff, an intro to Elasticsearch with Ruby/RailsFinding the right stuff, an intro to Elasticsearch with Ruby/Rails
Finding the right stuff, an intro to Elasticsearch with Ruby/Rails
Michael Reinsch
 
GNCTR 2012 Sponsors
GNCTR 2012 SponsorsGNCTR 2012 Sponsors
GNCTR 2012 Sponsorsosnorton
 
Positive Thinking
Positive ThinkingPositive Thinking
Positive Thinking
Excpy
 
Emerging Trends in Social Media 2013
Emerging Trends in Social Media 2013Emerging Trends in Social Media 2013
Emerging Trends in Social Media 2013
Excpy
 
Perio esthetics
Perio estheticsPerio esthetics
Perio esthetics
Jignesh Patel
 
Questionnaire on luxury brand shopping
Questionnaire on luxury brand shoppingQuestionnaire on luxury brand shopping
Questionnaire on luxury brand shopping
Kriace Ward
 
Twitter sentiment analysis
Twitter sentiment analysisTwitter sentiment analysis
Twitter sentiment analysis
Harshit Sanghvi
 
Periodontal management of medically compromised paients/dental courses
Periodontal management of medically compromised paients/dental coursesPeriodontal management of medically compromised paients/dental courses
Periodontal management of medically compromised paients/dental courses
Indian dental academy
 

Viewers also liked (18)

Ireland and Society, Lecture Three: Culture of Everyday Life
Ireland and Society, Lecture Three: Culture of Everyday LifeIreland and Society, Lecture Three: Culture of Everyday Life
Ireland and Society, Lecture Three: Culture of Everyday Life
 
Presentación12
Presentación12Presentación12
Presentación12
 
Ireland and Society, Lecture One: Religion
Ireland and Society, Lecture One:  ReligionIreland and Society, Lecture One:  Religion
Ireland and Society, Lecture One: Religion
 
Presentación1
Presentación1Presentación1
Presentación1
 
ColdEezeAdCampaign
ColdEezeAdCampaignColdEezeAdCampaign
ColdEezeAdCampaign
 
Mary Rose Buyoc Mangahas CV
Mary Rose Buyoc Mangahas CVMary Rose Buyoc Mangahas CV
Mary Rose Buyoc Mangahas CV
 
Jordan Michael Shaver's Resumé
Jordan Michael Shaver's Resumé Jordan Michael Shaver's Resumé
Jordan Michael Shaver's Resumé
 
11.05.2016 r. wyniki Lokum Deweloper I kw. 2016 r.
11.05.2016 r. wyniki Lokum Deweloper I kw. 2016 r.11.05.2016 r. wyniki Lokum Deweloper I kw. 2016 r.
11.05.2016 r. wyniki Lokum Deweloper I kw. 2016 r.
 
Sally.Hosseini-R.2015
Sally.Hosseini-R.2015Sally.Hosseini-R.2015
Sally.Hosseini-R.2015
 
Finding the right stuff, an intro to Elasticsearch with Ruby/Rails
Finding the right stuff, an intro to Elasticsearch with Ruby/RailsFinding the right stuff, an intro to Elasticsearch with Ruby/Rails
Finding the right stuff, an intro to Elasticsearch with Ruby/Rails
 
GNCTR 2012 Sponsors
GNCTR 2012 SponsorsGNCTR 2012 Sponsors
GNCTR 2012 Sponsors
 
Randeep
RandeepRandeep
Randeep
 
Positive Thinking
Positive ThinkingPositive Thinking
Positive Thinking
 
Emerging Trends in Social Media 2013
Emerging Trends in Social Media 2013Emerging Trends in Social Media 2013
Emerging Trends in Social Media 2013
 
Perio esthetics
Perio estheticsPerio esthetics
Perio esthetics
 
Questionnaire on luxury brand shopping
Questionnaire on luxury brand shoppingQuestionnaire on luxury brand shopping
Questionnaire on luxury brand shopping
 
Twitter sentiment analysis
Twitter sentiment analysisTwitter sentiment analysis
Twitter sentiment analysis
 
Periodontal management of medically compromised paients/dental courses
Periodontal management of medically compromised paients/dental coursesPeriodontal management of medically compromised paients/dental courses
Periodontal management of medically compromised paients/dental courses
 

Similar to async makes your tests fun - acceptance testing with capybara

Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010Ismael Celis
 
Async. and Realtime Geo Applications with Node.js
Async. and Realtime Geo Applications with Node.jsAsync. and Realtime Geo Applications with Node.js
Async. and Realtime Geo Applications with Node.jsShoaib Burq
 
Trying Continuous Delivery - pyconjp 2012
Trying Continuous Delivery - pyconjp 2012Trying Continuous Delivery - pyconjp 2012
Trying Continuous Delivery - pyconjp 2012Toru Furukawa
 
Remote code-with-expression-language-injection
Remote code-with-expression-language-injectionRemote code-with-expression-language-injection
Remote code-with-expression-language-injectionMickey Jack
 
Be Mean to your Code with Gauntlt #txlf 2013
Be Mean to your Code with Gauntlt #txlf 2013Be Mean to your Code with Gauntlt #txlf 2013
Be Mean to your Code with Gauntlt #txlf 2013
James Wickett
 
【第一季第二期】Dive into javascript event
【第一季第二期】Dive into javascript event【第一季第二期】Dive into javascript event
【第一季第二期】Dive into javascript eventtbosstraining
 
InterConnect: Server Side Swift for Java Developers
InterConnect:  Server Side Swift for Java DevelopersInterConnect:  Server Side Swift for Java Developers
InterConnect: Server Side Swift for Java Developers
Chris Bailey
 
Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016
Ben Lesh
 
Be Mean to Your Code - OWASP San Antonio
Be Mean to Your Code - OWASP San Antonio Be Mean to Your Code - OWASP San Antonio
Be Mean to Your Code - OWASP San Antonio James Wickett
 
Brining Harmony between Dev and Ops and Security Teams using Gauntlt at ISC2 ...
Brining Harmony between Dev and Ops and Security Teams using Gauntlt at ISC2 ...Brining Harmony between Dev and Ops and Security Teams using Gauntlt at ISC2 ...
Brining Harmony between Dev and Ops and Security Teams using Gauntlt at ISC2 ...
James Wickett
 
Dive into javascript event
Dive into javascript eventDive into javascript event
Dive into javascript event
Goddy Zhao
 
RxSwift to Combine
RxSwift to CombineRxSwift to Combine
RxSwift to Combine
Bo-Young Park
 
Gauntlt Rugged By Example
Gauntlt Rugged By ExampleGauntlt Rugged By Example
Gauntlt Rugged By Example
London School of Cyber Security
 
Rugged by example with Gauntlt (Hacker Headshot)
Rugged by example with Gauntlt (Hacker Headshot)Rugged by example with Gauntlt (Hacker Headshot)
Rugged by example with Gauntlt (Hacker Headshot)
James Wickett
 
Javascript in Plone
Javascript in PloneJavascript in Plone
Javascript in Plone
Steve McMahon
 
Event Driven Javascript
Event Driven JavascriptEvent Driven Javascript
Event Driven Javascript
Federico Galassi
 
Websocket on Rails
Websocket on RailsWebsocket on Rails
Websocket on Rails
Jeroen Rosenberg
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
Lindsay Holmwood
 

Similar to async makes your tests fun - acceptance testing with capybara (20)

Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010Websockets talk at Rubyconf Uruguay 2010
Websockets talk at Rubyconf Uruguay 2010
 
Async. and Realtime Geo Applications with Node.js
Async. and Realtime Geo Applications with Node.jsAsync. and Realtime Geo Applications with Node.js
Async. and Realtime Geo Applications with Node.js
 
Trying Continuous Delivery - pyconjp 2012
Trying Continuous Delivery - pyconjp 2012Trying Continuous Delivery - pyconjp 2012
Trying Continuous Delivery - pyconjp 2012
 
Remote code-with-expression-language-injection
Remote code-with-expression-language-injectionRemote code-with-expression-language-injection
Remote code-with-expression-language-injection
 
Be Mean to your Code with Gauntlt #txlf 2013
Be Mean to your Code with Gauntlt #txlf 2013Be Mean to your Code with Gauntlt #txlf 2013
Be Mean to your Code with Gauntlt #txlf 2013
 
【第一季第二期】Dive into javascript event
【第一季第二期】Dive into javascript event【第一季第二期】Dive into javascript event
【第一季第二期】Dive into javascript event
 
InterConnect: Server Side Swift for Java Developers
InterConnect:  Server Side Swift for Java DevelopersInterConnect:  Server Side Swift for Java Developers
InterConnect: Server Side Swift for Java Developers
 
Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016
 
Be Mean to Your Code - OWASP San Antonio
Be Mean to Your Code - OWASP San Antonio Be Mean to Your Code - OWASP San Antonio
Be Mean to Your Code - OWASP San Antonio
 
Brining Harmony between Dev and Ops and Security Teams using Gauntlt at ISC2 ...
Brining Harmony between Dev and Ops and Security Teams using Gauntlt at ISC2 ...Brining Harmony between Dev and Ops and Security Teams using Gauntlt at ISC2 ...
Brining Harmony between Dev and Ops and Security Teams using Gauntlt at ISC2 ...
 
Dive into javascript event
Dive into javascript eventDive into javascript event
Dive into javascript event
 
RxSwift to Combine
RxSwift to CombineRxSwift to Combine
RxSwift to Combine
 
Atmosphere 2014
Atmosphere 2014Atmosphere 2014
Atmosphere 2014
 
Gauntlt Rugged By Example
Gauntlt Rugged By ExampleGauntlt Rugged By Example
Gauntlt Rugged By Example
 
Rugged by example with Gauntlt (Hacker Headshot)
Rugged by example with Gauntlt (Hacker Headshot)Rugged by example with Gauntlt (Hacker Headshot)
Rugged by example with Gauntlt (Hacker Headshot)
 
Node.js
Node.jsNode.js
Node.js
 
Javascript in Plone
Javascript in PloneJavascript in Plone
Javascript in Plone
 
Event Driven Javascript
Event Driven JavascriptEvent Driven Javascript
Event Driven Javascript
 
Websocket on Rails
Websocket on RailsWebsocket on Rails
Websocket on Rails
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 

Recently uploaded

By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 

Recently uploaded (20)

By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 

async makes your tests fun - acceptance testing with capybara

  • 1. async makes your tests fun Michael Reinsch
 michael@movingfast.io
 github / twitter: mreinsch
  • 3. scenario "publish event" do visit event_url(event) click_on "Publish Event" expect(event.reload).to be_published end
  • 4. scenario "publish event", js: true do visit event_url(event) click_on "Publish Event" expect(event.reload).to be_published end
  • 5. scenario "publish event", js: true do visit event_url(event) click_on "Publish Event" expect(event.reload).to be_published end
  • 6. scenario "publish event", js: true do visit event_url(event) click_on "Publish Event" expect(event.reload).to be_published end Failure/Error: expect(event.reload).to be_published
  • 11. scenario "publish event", js: true do visit event_url(event) click_on "Publish Event" expect(page).to have_content("Registration: Open") expect(event.reload).to be_published end
  • 12. scenario "publish event", js: true do visit event_url(event) click_on "Publish Event" expect(page).to have_content("Registration: Open") expect(event.reload).to be_published end
  • 13. scenario "publish event", js: true do visit event_url(event) click_on "Publish Event" expect(page).to have_content("Registration: Open") expect(event.reload).to be_published end Failure/Error: Unable to find matching line from backtrace ActiveRecord::StatementInvalid: PG::TRDeadlockDetected: ERROR: deadlock detected DETAIL: Process 7186 waits for AccessShareLock on relation 16570 of database 16396; blocked by process 7274. Process 7274 waits for AccessExclusiveLock on relation 17012 of database 16396; blocked by process 7186.
  • 15. # in spec/spec_helper.rb config.append_after(:each) do Rails.logger.debug("======= cleaning DB") DatabaseCleaner.clean end
  • 16. module RSpecLoggerListener extend self def start(notification) Rails.logger.info("nn====== Starting new test run") end def stop(notification) Rails.logger.info("nn====== Test run finished") end def example_started(notification) Rails.logger.info("nn====== START #{notification.example.full_description}") end def example_passed(notification) Rails.logger.info("====== PASSED #{notification.example.full_description}") end def example_failed(notification) Rails.logger.info("====== FAILED #{notification.example.full_description}") end def example_pending(notification) Rails.logger.info("====== PENDING #{notification.example.full_description}") end end RSpec.configuration.reporter.register_listener( RSpecLoggerListener, :start, :stop, :example_started, :example_passed, :example_failed, :example_pending) get it from: https://gist.github.com/mreinsch/2c8dbb01e51c32c3c5c8
  • 17. module CapybaraHelperMethods def wait_for_ajax counter = 0 while !finished_all_ajax_requests? counter += 1 sleep 0.2 raise "AJAX request took too long." if counter >= (Capybara.default_wait_time * 5) end end def finished_all_ajax_requests? active = page.evaluate_script <<-SCRIPT.strip.gsub(/s+/,' ') (function () { if (typeof jQuery != 'undefined') { return jQuery.active; } else { console.error("jQuery was undefined on " + document.URL + " - will retry..."); return -1; } })() SCRIPT active && active.zero? end end RSpec.configuration.include CapybaraHelperMethods, :type => :feature based on https://coderwall.com/p/aklybw/wait-for-ajax-with-capybara-2-0
  • 18. scenario "publish event", js: true do visit event_url(event) click_on "Publish Event" expect(page).to have_content("Registration: Open") expect(event.reload).to be_published wait_for_ajax end
  • 19. Beware of the async! Michael Reinsch
 michael@movingfast.io
 github / twitter: mreinsch