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
80
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
Transcript
12 slides
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
Other Decks in Programming
See All in Programming
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
240
[DroidKnights 2026] Workflow AX 적용기 — 자동 정책 정리부터 E2E까지
dayeon
0
120
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
180
AIがコードを書いてくれる時代、我々は何を確かめるのか
yosuke_furukawa
PRO
13
6.2k
眠らない開発チームの作り方
biwakonbu
0
120
Growing PicoRuby's Ecosystem on ESP32
yuuu
2
150
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
480
AIが実装を担う時代の「技術設計」と「チームマネジメント」
kamina_zzz
2
450
なぜ私たちは「現時点では」KMPの導入を見送ったのか
chigichan24
1
640
LLM 101
dalinaum
0
540
数行の変更でDockerビルドを最大91%高速化~GitLab CIの実行基盤を社内40リポジトリに展開するまで~
picopico
3
680
読みやすい!と評判(?)の発表の準備にかける私のこだわり
shoheimitani
0
170
Featured
See All Featured
Digital Ethics as a Driver of Design Innovation
axbom
PRO
2
560
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
61k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.7k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.2k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
850
30 Presentation Tips
portentint
PRO
1
480
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.2k
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
Are puppies a ranking factor?
jonoalderson
2
4.2k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
121
130k