SpockからRSpecに
きたときの気づき
@PoohSunny
2016/04/10
Ruby / Rails ビギナーズ勉強会 第12回
こんにちは!
あらためまして
自己紹介
● @PoohSunny
● 仕事はWEBサービスのScrum Developer
● Rails歴2ヶ月
● Javaから来ました
● Groovy、Grails、Gradleが好きです。
● コミュニティ
○ TDDBC
○ Agile Samurai Base Camp
○ 日本Seleniumユーザーコミュニティ
よろしく
お願いします!
今日の話
今日の話
● Spock
○ Groovy製のBDDフレーム
ワーク
● RSpec
○ Ruby製のBDDフレームワー
ク
脳内を移行したとき
に気づいたこと
とりあえず書いた
テスト
describe User do
context "no validation" do
it "should pass all validation" do
user = User.new(name: "samplename-_1")
actual = user.valid?
actual.should eq true
end
end
デキる人に
レビュー
してもらう
describe User do
context "no validation" do
it "should pass all validation" do
user = User.new(name: "samplename-_1")
actual = user.valid?
actual.should eq true
end
end
※練習ということでFactory Girlは使っていません
describe User do
describe "#validate" do
context "all valid" do
let(:result) { User.new(name: "samplename-_1").valid? }
it { result.should be_truthy }
end
変えたこと
describe User do
describe "#validate" do
context "all valid" do
let(:result) { User.new(name: "samplename-_1").valid? }
it { result.should be_truthy }
end
構造を変更
テスト結果を意識する
describe User do
describe "#validate" do
context "all valid" do
let(:result) { User.new(name: "samplename-_1").valid? }
it { result.should be_truthy }
end
フェーズをまとめる
describe User do
describe "#validate" do
context "all valid" do
let(:result) { User.new(name: "samplename-_1").valid? }
it { result.should be_truthy }
end
letは最初すこし戸惑ったけど便利
describe User do
describe "#validate" do
context "all valid" do
let(:result) { User.new(name: "samplename-_1").valid? }
it { result.should be_truthy }
end
実測値の変数名問題
describe User do
describe "#validate" do
context "all valid" do
let(:result) { User.new(name: "samplename-_1").valid? }
it { result.should be_truthy }
end
trueっぽいは便利っぽい
参考:
http://blog.livedoor.jp/dankogai/archives/51704592.html
describe User do
describe "#validate" do
context "all valid" do
let(:result) { User.new(name: "samplename-_1").valid? }
it { result.should be_truthy }
end
今のところshouldが好きです
感想
RSpec、ゆるい
だがそれがいい
自分の「当然」は
本当に当然?
郷に入っては
郷に従う
おしまい

SpockからRSpecにきたときの気づき #coedorb