Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Leave end-to-end testing to Capybara
Search
SHIBATA Hiroshi
October 11, 2011
0
600
Leave end-to-end testing to Capybara
SHIBATA Hiroshi
October 11, 2011
Tweet
Share
More Decks by SHIBATA Hiroshi
See All by SHIBATA Hiroshi
How to make faster release cycle of Ruby?
hsbt
2
4.7k
Ruby の開発を支えるエコシステム
hsbt
4
1.9k
Why is building the Ruby environment hard?
hsbt
6
5.6k
開発環境へのこだわり
hsbt
15
12k
OSS ことはじめ
hsbt
5
1.2k
GMO DevNight 05 在宅勤務開始から2ヶ月でやったこと
hsbt
2
430
Development Environment 2019
hsbt
1
280
How to become the Psychic
hsbt
0
1.7k
Software Development
hsbt
1
6.2k
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
350
18k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
101
6.6k
Build The Right Thing And Hit Your Dates
maggiecrowley
23
1.9k
A designer walks into a library…
pauljervisheath
199
23k
Design by the Numbers
sachag
274
18k
Become a Pro
speakerdeck
PRO
8
4.4k
Keith and Marios Guide to Fast Websites
keithpitt
407
22k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
111
35k
Docker and Python
trallard
33
2.6k
For a Future-Friendly Web
brad_frost
170
8.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
153
14k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
319
20k
Transcript
Leave end-to- end testing to Capybara SHIBATA Hiroshi Eiwa System
Management,Inc.
1SPpMF
SHIBATA Hiroshi a.k.a hsbt tDiary commiter
[email protected]
http://twitter.com/hsbt/ http://www.hsbt.org/ http://github.com/hsbt/
asakusa.rb
SapporoRubyKaigi
RubyKaigi 2010
None
ࠓ͢͜ͱ
தͷਓͨͪ
None
None
None
None
None
None
None
Ͳ͏ͬͯ
Capybara
None
CapybaraΤϯυ πʔΤϯυςετΛࢧ ͑ΔϑϨʔϜϫʔΫ
࣮ߦڥ
None
None
capybara RSpec DSL cucumber DSL cucumber DSL(ja) RSpec runner cucumber
runner
RSpec Example
DSL feature 'هΛಡΉ' do background do setup_tdiary end scenario '࠷৽ͷهͷදࣔ'
do visit '/' within('title') do page.should have_content('ʲهʳ') } end within('h1') do page.should have_content('ʲهʳ') end page.should have_css('a[href="update.rb"]') ! end end
Cucumber Example
None
Driver
None
Driverͷ ؒୡ
3BDL ૣ͍ɺKT͕ಈ͔ͳ͍͔ )UNM6OJU ͦͦ͜͜ૣ͍ɺKT͕ಈ͘ KBWBTDSJQUFOHJOF KT͕ΘΓͱΑ͘ಈ͘ TFMFOJVN ϒϥβͦͷͷ
None
HtmlUnit
BLFQIBMPT *& 'JSFGPY DVMFSJUZDFMFSJUZ +3VCZ
javascript engine
FOWKT KIPOTPO XFCLJU 25 [POCJF UFTUJOHGPSOPEFKT
Selenium Webdriver
None
require ‘capybara/dsl’ RSpec.configure do |config| config.include Capybara config.before(:all, :selenium =>
true) do Capybara.current_driver = :selenium end end
ςετͷߴԽ ͱϦζϜ http://www.ne.jp/asahi/t/wada/articles/Refactoring_and_Test.pdf
TFMFOJVNNFDIBOJ[F ͍͍͍ͩͨ
best mix
config.before(:all, :selenium => true) do Capybara.current_driver = :selenium end config.after(:all,
:selenium => true) do Capybara.use_default_driver end DSL
feature "͓٬༷৽نՃ", :selenium => true do let!(:administrator) { User.make! }
before do login_as administrator visit new_admin_user_path end scenario "ཧऀΛొͰ͖Δ͜ͱ" do (লུ) end end DSL
capybara/rspec
DSL feature "͓٬༷৽نՃ", :driver => :akephalos do scenario "ཧऀΛొͰ͖Δ͜ͱ" do
(লུ) end end feature "͓٬༷มߋ", :js => true do scenario "ཧऀΛมߋͰ͖Δ͜ͱ" do (লུ) end end => :driver = :selenium ͱಉ͡
ศར!!!
None
'JOBM3VCZ,BJHJʹདྷΔ Β͍͠ Α
RubyKaigi 2011 ࿅അͰͱѲख
(PPE3VCZ-JGF