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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
kbaba1001
December 08, 2014
Technology
330
0
Share
Turnip
TokyuRubyKaigi 08
kbaba1001
December 08, 2014
More Decks by kbaba1001
See All by kbaba1001
How to build a video conferencing system that no one has ever told you about
kbaba1001
0
59
Build React system with ClojureScript (Squint)
kbaba1001
0
150
talk-with-local-llm-with-web-streams-api
kbaba1001
0
480
Lume: Static Site Generator
kbaba1001
0
680
React_2023
kbaba1001
0
200
Word Penne
kbaba1001
0
230
I live by using a minor language
kbaba1001
1
200
fast optical line
kbaba1001
0
400
ArtPosePro and Procreate
kbaba1001
1
240
Other Decks in Technology
See All in Technology
データを"持てない"環境でのアノテーション基盤設計
sansantech
PRO
1
100
Master Dataグループ紹介資料
sansan33
PRO
1
4.6k
AgentCore×VPCでの設計パターンn選と勘所
har1101
3
260
基盤を育てる 外部SaaS連携の運用
gamonges_dresscode
1
110
20260423_執筆の工夫と裏側 技術書の企画から刊行まで / From the planning to the publication of technical book
nash_efp
3
370
最新の脅威動向から考える、コンテナサプライチェーンのリスクと対策
kyohmizu
1
680
目的ファーストのハーネス設計 ~ハーネスの変更容易性を高めるための優先順位~
gotalab555
8
2k
The Journey of Box Building
tagomoris
4
1.3k
AI와 협업하는 조직으로의 여정
arawn
0
110
JEDAI in Osaka 2026イントロ
taka_aki
0
290
Revisiting [CLS] and Patch Token Interaction in Vision Transformers
yu4u
0
340
20年前の「OSS革命」に学ぶ AI時代の生存戦略
samakada
0
330
Featured
See All Featured
Fireside Chat
paigeccino
42
3.9k
Designing Experiences People Love
moore
143
24k
Claude Code のすすめ
schroneko
67
220k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
710
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
260
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
180
SEO for Brand Visibility & Recognition
aleyda
0
4.5k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.3k
Navigating Team Friction
lara
192
16k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
280
Statistics for Hackers
jakevdp
799
230k
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