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.4k
Ruby の開発を支えるエコシステム
hsbt
4
2.2k
Why is building the Ruby environment hard?
hsbt
6
7.1k
開発環境へのこだわり
hsbt
16
12k
OSS ことはじめ
hsbt
5
1.3k
GMO DevNight 05 在宅勤務開始から2ヶ月でやったこと
hsbt
2
500
Development Environment 2019
hsbt
1
320
How to become the Psychic
hsbt
0
1.9k
Software Development
hsbt
1
6.4k
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
427
65k
Practical Orchestrator
shlominoach
186
10k
The World Runs on Bad Software
bkeepers
PRO
67
11k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Site-Speed That Sticks
csswizardry
4
400
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.4k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.5k
Designing for Performance
lara
604
68k
Mobile First: as difficult as doing things right
swwweet
223
9.4k
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