In many of the examples, such as Let Grouping and Leading Subject, it implies that the spec structure should be:
describe Article do
subject { FactoryBot.create(:some_article) }
let(:user) { FactoryBot.create(:user) }
before do
# ...
end
describe '#summary' do
# ...
end
end
where the let is declared before the before block. Is this a correct assumption and should it be in the style guide?
# Bad
describe Article do
subject { FactoryBot.create(:some_article) }
before do
# ...
end
let(:user) { FactoryBot.create(:user) }
describe '#summary' do
# ...
end
end
# Good
describe Article do
subject { FactoryBot.create(:some_article) }
let(:user) { FactoryBot.create(:user) }
before do
# ...
end
describe '#summary' do
# ...
end
end
In many of the examples, such as Let Grouping and Leading Subject, it implies that the spec structure should be:
where the
let
is declared before thebefore
block. Is this a correct assumption and should it be in the style guide?