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
Turnip
Search
kbaba1001
December 08, 2014
Technology
0
310
Turnip
TokyuRubyKaigi 08
kbaba1001
December 08, 2014
Tweet
Share
More Decks by kbaba1001
See All by kbaba1001
talk-with-local-llm-with-web-streams-api
kbaba1001
0
260
Lume: Static Site Generator
kbaba1001
0
500
React_2023
kbaba1001
0
140
Word Penne
kbaba1001
0
150
I live by using a minor language
kbaba1001
0
130
fast optical line
kbaba1001
0
340
ArtPosePro and Procreate
kbaba1001
1
160
How did Clojure change my life
kbaba1001
3
1.8k
The Pragmatic Hanami
kbaba1001
0
1.9k
Other Decks in Technology
See All in Technology
Change Managerを活用して本番環境へのセキュアなGUIアクセスを統制する / Control Secure GUI Access to the Production Environment with Change Manager
yuj1osm
0
110
株式会社Awarefy(アウェアファイ)会社説明資料 / Awarefy-Company-Deck
awarefy
3
11k
Share my, our lessons from the road to re:Invent
naospon
0
150
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
3
530
あなたが人生で成功するための5つの普遍的法則 #jawsug #jawsdays2025 / 20250301 HEROZ
yoshidashingo
2
310
クラウド食堂とは?
hiyanger
0
120
目標と時間軸 〜ベイビーステップでケイパビリティを高めよう〜
kakehashi
PRO
8
710
OSS構成管理ツールCMDBuildを使ったAWSリソース管理の自動化
satorufunai
0
660
生成AI “再”入門 2025年春@WIRED TUESDAY EDITOR'S LOUNGE
kajikent
0
140
AIエージェント時代のエンジニアになろう #jawsug #jawsdays2025 / 20250301 Agentic AI Engineering
yoshidashingo
8
3.9k
Amazon Aurora のバージョンアップ手法について
smt7174
2
160
実は強い 非ViTな画像認識モデル
tattaka
3
1.3k
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
10
520
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
Mobile First: as difficult as doing things right
swwweet
223
9.5k
It's Worth the Effort
3n
184
28k
Rebuilding a faster, lazier Slack
samanthasiow
80
8.9k
Into the Great Unknown - MozCon
thekraken
35
1.6k
Optimising Largest Contentful Paint
csswizardry
34
3.1k
Writing Fast Ruby
sferik
628
61k
GitHub's CSS Performance
jonrohan
1030
460k
Transcript
Turnip Turnip @kbaba1001 Powered by Rabbit 2.1.3 and COZMIXNG
自己紹介 kbaba1001 Ruby on Rails 永和システムマネジメント
kbaba1001食堂 ?
今日の話
Turnip とは Acceptance Test Framework @jnicklas (capybara、xpath)
特徴 Gherkin でシナリオテストを書く RSpec の拡張として動く Spinach より機能が多い
Gherkin フィーチャ: kbaba1001として料理を作る シナリオ: ワインシリアルを作る 前提 "ワイン" がある かつ "シリアル"
がある かつ 冷蔵庫が空である もし kbaba1001が空腹である ならば "ワインシリアル" を作ること
RSpecでのステップ定義 # spec/acceptance/steps/food_steps.rb steps_for :food do step ":name がある" do
|name| Food.create!(name: name) end end
Cucumber との比較 スコープ付きステップ 正規表現 → Placeholder
スコープ付きステップ steps_for :food do step ":name がある" do |name| Food.create!(name:
name) end end steps_for :tool do step ":name がある" do |name| Tool.create!(name: name) end end
スコープ付きステップ @food シナリオ: ワインシリアルを作る 前提 "ワイン" がある かつ "シリアル" がある
@tool シナリオ: ショートケーキを作る 前提 "電動ドリル" がある かつ "手動泡立て機" がある
Placeholder step ":food が :count ある/いる" do |food, count| end
placeholder :count do match /\d+(個|羽|丁)/ do |count| count.to_i end match(/(.+)/) {|count| 10 } end
なんか良さそう!!
プロジェクトで使ってみた Rails 期間: 1 年間 ほぼ全画面を Turnip でテスト
LOC 全体 feature s steps model spec 25,000 6,000 1,300
6,000
Turnip感想 RSpecに組み込めるのがよい 規模が大きくなるとつらい
つらみ スコープが混ざる
スコープが混ざる steps_for :food do step ":name がある" do |name| ...
steps_for :tool do step ":name がある" do |name| ... # step を重複定義するのでエラー @food @tool シナリオ: ワインシリアルを作る 前提 "ワイン" がある かつ "電動ドリル" がある
回避方法 steps_for :food do step "食べ物 :name がある" do |name|
... steps_for :tool do step "道具 :name がある" do |name| ... @food @tool シナリオ: ワインシリアルを作る 前提 食べ物 "ワイン" がある かつ 道具 "電動ドリル" がある
( ˘ω˘) スコープとは何だったのか…
つらみ Custom Step Placeholder でスコ ープが使えない placeholder :count do match
/\d+(個|羽|丁)/ do |count| count.to_i end match(/(.+)/) {|count| 10 } end
長い… placeholder :page do helper = Rails.application.routes.url_helpers match(/トップページ/) { helper.root_path
} match(/ユーザーマイページ/) { helper.authenticated_root_path } match(/管理者マイページ/) { helper.admin_authenticated_root_path } match(/プロフィール登録ページ/) { helper.profile_path } # 中略... match(/(.+)/) {|page| page } end
( ˘ω˘) スコープとは何だったのか…
Step をまとめづらい シナリオ: もし "ワインシリアル" と表示すること かつ "ヘッダー" に "ワインシリアル"
と表示すること step ':text と表示すること' do |text| expect(page).to have_content(text) end step ':parent に :text と表示すること' do |parent, text| within(parent) do send ':text と表示すること', text end end
( ˘ω˘) 正規表現は善!!
まとめ Turnip は小さいプロジェクトで RSpec の拡張として使うには手 頃。 本格的にシナリオテストを書くな ら Cucumber。 Powered
by Rabbit 2.1.3 and COZMIXNG