DEV Community

Vasily Polovnyov
Vasily Polovnyov

Posted on

RSpec: 3 things you should stop writing in example descriptions

1. Useless, general phrases saying nothing about what method is actually doing:

it "adds certain value"
it "returns correct result"
it "fails"
it "returns formatted string"
it "returns correct url"
it "is ok"
Enter fullscreen mode Exit fullscreen mode

2. Implementation details:

it "changes @scheduled_on"
it "assigns @todos"
Enter fullscreen mode Exit fullscreen mode

3. Lies:

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
Enter fullscreen mode Exit fullscreen mode

Top comments (0)