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.6k
Ruby の開発を支えるエコシステム
hsbt
4
2.2k
Why is building the Ruby environment hard?
hsbt
6
7.5k
開発環境へのこだわり
hsbt
16
12k
OSS ことはじめ
hsbt
5
1.4k
GMO DevNight 05 在宅勤務開始から2ヶ月でやったこと
hsbt
2
530
Development Environment 2019
hsbt
1
340
How to become the Psychic
hsbt
0
2k
Software Development
hsbt
1
6.5k
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
270
20k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
43
2.4k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.4k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
60k
The World Runs on Bad Software
bkeepers
PRO
69
11k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.6k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Automating Front-end Workflow
addyosmani
1370
200k
Balancing Empowerment & Direction
lara
1
340
Building an army of robots
kneath
306
45k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.6k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
22k
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