Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Capybara & AJAX: die ultimative Lösung?
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Taktsoft
September 02, 2013
Programming
79
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Capybara & AJAX: die ultimative Lösung?
Präsentation:
http://bit.ly/15v0ynO
Code:
http://bit.ly/1cBdZ4M
Taktsoft
September 02, 2013
Other Decks in Programming
See All in Programming
[JA] Domain Modeling with Vanilla Rails: 「操作」から再考するRailsの設計論
yasaichi
2
400
Verilogで学ぶCPU自作入門
uyuki234
8
4.1k
IBM Bob でAI駆動開発『QC-Playbook』
ichirokano2
0
110
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
260
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
220
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
2
770
最近”作らせてる” ローカルAIアプリの話
akit37
0
480
Performance Optimization With LLMs
xleitix
0
120
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.9k
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
380
Event is what happens
moro
2
850
カツオ、ご期待ください
suneo3476
0
190
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
570
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
710
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
HDC tutorial
michielstock
2
960
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
Designing Experiences People Love
moore
143
24k
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
270
Deep Space Network (abreviated)
tonyrice
0
370
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Transcript
Taktsoft Wissensaustausch Capybara & AJAX: die ultimative Lösung?
einfaches Beispiel • Rails 3 Application ◦ PostgreSQL ◦ Poltergeist
/ PhantomJS • Post (Title & Body) ◦ Create & Destroy via AJAX
Feature-Spec it "creates a new post on submit" do visit
posts_path page.click_on "New Post" page.fill_in 'Title', with: "Foo" page.fill_in 'Body', with: "Bar" expect { page.click_on "Create Post" }.to change(Post, :count).from(0).to(1) end
1 example, 1 failure
Probleme • ID des neuen Datensatzes nicht bekannt! ◦ kein:
page.should have_css “#model_#{id}” • Class nur für den Test setzen? ◦ Kein App-Code damit Test funktioniert • sleep(Capybara.default_wait_time) ◦ Nicht die feine Art
Vorschlag • jQuery.ajaxStart & jQuery.ajaxStop ◦ globale AJAX-Event-Handler • AJAX-Status
an Attribut setzen / erkennen ◦ z.B. am immer verfügbaren body-Tag
Implementierung (1) page.execute_script <<-EOS $(document).ready(function() { $('body').attr('data-ajax-status', 'stop'); }); $(document).ajaxStart(function()
{ $('body').attr('data-ajax-status', 'start'); }); $(document).ajaxStop(function() { $('body').attr('data-ajax-status', 'stop'); }); EOS
page.should have_css "body[data-ajax-status=stop]" • Jeweils über eine Helper-Methode aufrufbar ◦
wait_for_ajax_install (1) ◦ wait_for_ajax_stop (2) • install nach visit • stop vor assert Implementierung (2)
1 example, 0 failures
Ausblick • Berücksichtigung von Nebenläufigkeit ◦ Mehrere AJAX-Requests überschneiden sich
• Verankerung in RSpec ◦ kein expliziter Aufruf der Helper • Erweiterung als Gem ◦ nächster Wissensaustausch … ;)
Vielen Dank Präsentation: http://bit.ly/15v0ynO Code: http://bit.ly/1cBdZ4M
Hidden Page • using_wait_time(seconds) { … } ◦ führt einen
Block mit der angegebenen wait time aus • page.should have_css “#foo”, wait: 5 ◦ führt die expectation mit der angegebenen wait time aus