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
610
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.2k
Ruby の開発を支えるエコシステム
hsbt
4
2.1k
Why is building the Ruby environment hard?
hsbt
6
6.8k
開発環境へのこだわり
hsbt
15
12k
OSS ことはじめ
hsbt
5
1.3k
GMO DevNight 05 在宅勤務開始から2ヶ月でやったこと
hsbt
2
480
Development Environment 2019
hsbt
1
310
How to become the Psychic
hsbt
0
1.9k
Software Development
hsbt
1
6.4k
Featured
See All Featured
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
860
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Into the Great Unknown - MozCon
thekraken
32
1.5k
We Have a Design System, Now What?
morganepeng
50
7.2k
Site-Speed That Sticks
csswizardry
0
24
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
120
Scaling GitHub
holman
458
140k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
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