Skip to content

Conversation

@p17m0
Copy link

@p17m0 p17m0 commented Mar 2, 2025

No description provided.

gem "selenium-webdriver"
end

gem "factory_bot", "~> 6.5"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тоже лучше делать в блоке development/test

title { 'New title' }
association :author, factory: :author

trait :with_archived_status do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

с одной стороны, ты аккуратно сделал через trait, но лучше использовать этот механизм для более сложных переиспользуемых случаев. Один атрибут лучше выставлять прямо в тесте передавая такие атрибуты в фабрику FactoryBot.build(:podcast, title: nil)

factory :podcast do
status { 'new' }
title { 'New title' }
association :author, factory: :author
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

супер, что нашел эту конструкцию

end

it 'should be possible to add comment' do
comments_before = episode.comments.count
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для этого более выразительно будет использовать change, как ты делаешь ниже

let(:podcast_with_blocked_author) { build(:podcast, :with_blocked_author) }

it 'should be invalid when no author' do
expect(podcast_no_author.valid?).to eq(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут лучше использовать be_valid


context 'when user subscribed' do
it 'should include user' do
expect(subscription.user == subscriber).to eq(true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут лучше использовать expect(subscription.user).to eq(subscriber)

context 'when has published episode' do
it "is expected to include episode" do
podcast.publish(episode)
expect(podcast.episodes).to be_any
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В описании теста пишем, что ошжидаем, что конкретный эпизод будет в коллекции, а в проверке проверяем, что там вообще что-то есть. То есть, содержимое не соответствует описанию

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants