Skip to content

4 controllers tests#2

Open
ksilex wants to merge 4 commits into
3_tddfrom
4_controllers_tests
Open

4 controllers tests#2
ksilex wants to merge 4 commits into
3_tddfrom
4_controllers_tests

Conversation

@ksilex
Copy link
Copy Markdown
Owner

@ksilex ksilex commented Mar 3, 2021

No description provided.

it 'saves a new answer in the database' do
expect { post :create, params: { answer: attributes_for(:answer),
question_id: answer.question }
}.to change(Answer, :count).by(1)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

тут стоит в change указать question.answers, чтобы сразу проверить, что ответ связывается с вопросом

Comment thread spec/factories/answers.rb
body { "MyString" }
question { nil }
body { "MyText" }
association :question
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

если имя ассоциации и фабрики совпадает, то можно вместо association :question писать просто question

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