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
330
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
75
Build React system with ClojureScript (Squint)
kbaba1001
0
190
talk-with-local-llm-with-web-streams-api
kbaba1001
0
540
Lume: Static Site Generator
kbaba1001
0
720
React_2023
kbaba1001
0
210
Word Penne
kbaba1001
0
240
I live by using a minor language
kbaba1001
1
220
fast optical line
kbaba1001
0
420
ArtPosePro and Procreate
kbaba1001
1
260
Other Decks in Technology
See All in Technology
SRENEXT_2026_Chairs__Talks_in_Tamachi.sre.pdf
srenext
1
140
どこまでAIに任せるか 〜確率論と決定論の境界決定〜
shukob
0
440
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
15
110k
AI Native なプロダクト組織の立ち上げ方 : 生産性 100 倍への挑戦
mikesorae
0
1.2k
複数プロダクトで進めるAI機能実装 ── 実践から得たリアルな学びとロードマップ実現への挑戦 / AICon2026_yanari
rakus_dev
1
270
2年前に削除したPHPクラスが、 ある日突然決済をエラーにした
ykagano
1
750
なぜ、あなたのAPIは使われないのか? AX時代の設計原則、ガードレール、運用体制
yokawasa
1
210
文字起こし基盤の信頼性
abnoumaru
0
120
壊して学ぶAWS CDK: そのcdk deployで消えるもの、残るもの
k_adachi_01
1
480
Jitera Company Deck
jitera
0
270
OpenTelemetryにおけるGoのゼロコード・コンパイル時計装について #fukuokago
quiver
0
200
凡エンジニアがこの先生きのこるためには。〜TypeScript完全に理解したい〜
alchemy1115
2
410
Featured
See All Featured
So, you think you're a good person
axbom
PRO
2
2.1k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
270
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Google's AI Overviews - The New Search
badams
0
1.1k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
350
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
770
The Limits of Empathy - UXLibs8
cassininazir
1
530
Ruling the World: When Life Gets Gamed
codingconduct
0
290
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
190
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
350
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