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
620
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
5.7k
Ruby の開発を支えるエコシステム
hsbt
4
2.2k
Why is building the Ruby environment hard?
hsbt
6
7.6k
開発環境へのこだわり
hsbt
16
12k
OSS ことはじめ
hsbt
5
1.4k
GMO DevNight 05 在宅勤務開始から2ヶ月でやったこと
hsbt
2
540
Development Environment 2019
hsbt
1
340
How to become the Psychic
hsbt
0
2k
Software Development
hsbt
1
6.5k
Featured
See All Featured
Fireside Chat
paigeccino
39
3.6k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Unsuck your backbone
ammeep
671
58k
Site-Speed That Sticks
csswizardry
10
770
A Tale of Four Properties
chriscoyier
160
23k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.4k
Java REST API Framework Comparison - PWX 2021
mraible
33
8.8k
Why You Should Never Use an ORM
jnunemaker
PRO
58
9.5k
Embracing the Ebb and Flow
colly
86
4.8k
Building Applications with DynamoDB
mza
96
6.6k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
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