RSpec & Rails: `it`에 쓰지 말아야 할 것

1. 가치가 없는 쓸모없고 일반적인 단어:

# bad: what value? for what?
it "adds certain value"

# good
it "snoozes for an extra 5 minutes"


# bad: which result is correct?
it "returns correct result"

# good
it "returns user's initials"


# bad: how exactly it fails?
it "fails"

# good
it "raises a not found error"


# bad: formatted how?
it "returns formatted string"

# good
it "returns time in 24-hour format"

# bad: what 'ok' means?
it "is ok"

# good
it "creates draft invoices"


2. 시행 세부사항:

# bad
it "changes @scheduled_on"

# good
it "reschedules campaign"


# bad
it "sets @todos"

# good
it "assigns todos to a given user"


3. 거짓말:

it "returns time in 24-hour format" do
  expect(...).to eq "9:25"
end

it "strips leading zeroes" do
  expect(foo(" 9:25 ")).to eq "9:25"
end


또한보십시오:
RSpec Style Guide
Better Specs

좋은 웹페이지 즐겨찾기