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
320
Turnip
TokyuRubyKaigi 08
kbaba1001
December 08, 2014
Tweet
Share
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
33
Build React system with ClojureScript (Squint)
kbaba1001
0
110
talk-with-local-llm-with-web-streams-api
kbaba1001
0
410
Lume: Static Site Generator
kbaba1001
0
600
React_2023
kbaba1001
0
170
Word Penne
kbaba1001
0
190
I live by using a minor language
kbaba1001
1
160
fast optical line
kbaba1001
0
360
ArtPosePro and Procreate
kbaba1001
1
200
Other Decks in Technology
See All in Technology
アウトプットから始めるOSSコントリビューション 〜eslint-plugin-vueの場合〜 #vuefes
bengo4com
3
1.8k
入院医療費算定業務をAIで支援する:包括医療費支払い制度とDPCコーディング (公開版)
hagino3000
0
110
ラスベガスの歩き方 2025年版(re:Invent 事前勉強会)
junjikoide
0
130
生成AI時代のPythonセキュリティとガバナンス
abenben
0
140
ブラウザのAPIで Nintendo Switch用の特殊なゲーム用コントローラーを体験型コンテンツに / IoTLT @ストラタシス・ジャパン
you
PRO
0
140
re:Inventに行くまでにやっておきたいこと
nagisa53
0
170
From Natural Language to K8s Operations: The MCP Architecture and Practice of kubectl-ai
appleboy
0
230
SQLAlchemy の select(User).where(User.id =="123") を理解してみる/sqlalchemy deep dive
3l4l5
3
380
AIでデータ活用を加速させる取り組み / Leveraging AI to accelerate data utilization
okiyuki99
0
240
Open Table Format (OTF) が必要になった背景とその機能 (2025.10.28)
simosako
2
230
Behind Postgres 18: The People, the Code, & the Invisible Work | Claire Giordano | PGConfEU 2025
clairegiordano
0
130
ヘンリー会社紹介資料(エンジニア向け) / company deck for engineer
henryofficial
0
390
Featured
See All Featured
Designing for Performance
lara
610
69k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
What's in a price? How to price your products and services
michaelherold
246
12k
Building an army of robots
kneath
305
46k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
140
34k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Why Our Code Smells
bkeepers
PRO
340
57k
How to Ace a Technical Interview
jacobian
280
24k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
130k
The World Runs on Bad Software
bkeepers
PRO
72
11k
Automating Front-end Workflow
addyosmani
1371
200k
Leading Effective Engineering Teams in the AI Era
addyosmani
7
630
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