Home>
I am creating a simple article app with rails.
In the part ①, the title of # article_params and @ article.title
I'd like to write test code to make sure the values match
I would appreciate it if you could tell me how to write it.
I wrote it as below, but because = is not recognized as a match
I think the writing style is different.
assigns [: article] .title = article_params.title
describe'POST #create' do
context'logged in' do
login_user
before {post: create, params: {article: article_params}}
context'no input error' do
context'If i don't post an image' do
let (: article_params) {attributes_for (: article)}
it'result' do
#response
is_expected.to respond_with (: redirect)
is_expected.to redirect_to (articles_path)
#assigns
①
expect (assigns [: article] .persisted?). To be_truthy
#flash
is_expected.to set_flash [: notice]
.to (I18n.t ('label.create_success', model: Article.model_name.human))
end
end
-
Answer # 1
Related articles
- ruby on rails - i want to write a rails tutorial test in rspec
- ruby on rails - rspec of the like function how to get the number of likes or how to reflect by clicking the icon
- ruby on rails - rails rspec argumenterror occurs when the mock under test has arguments
- ruby on rails - how to write a form object
- ruby - rails json i don't know how to write json conditional branch that is returned when selected
- ruby on rails - no route matches , missing required keys: [: id] cannot be resolved
- ruby on rails - it works fine on the browser, but the rspec test doesn't pass
- [ruby on rails] how to write when getting a model nested in multiple stages with includes
- ruby on rails - rspec conditional validation
- ruby on rails - phenomenon that the test that should be an "rspec" error passes
- no route matches [patch] i want to resolve the error ruby on rails
- ruby on rails 5 - rspec controller test doesn't work
- ruby on rails - rails6 rspec integration test error
- ruby on rails - about request spec of rspec about test code at login
- ruby on rails - how to deal with status code 422 in the post request test with rspec
- ruby on rails - [rails] i want to solve "no route matches [post]"/messages/search "" of "routing error&
- ruby on rails - rspec validation error
- ruby on rails - rspec test changed by -1, but was changed by 0 error
- ruby - [rails] i want to find the date difference using the model created_at
Related questions
- ruby on rails - how to resolve lib/rack/session/abstract/idrb: 375: in'commit_sesion' that occurs in rspec
- ruby - [rspec] error in "dependent: destoy" test: how to resolve "validation failed"
- ruby - rails tutorial chapter 13 delete does not work in the test of increasing/decreasing the number of posts with rspec
- ruby - [rails/rspec] intermediate table model test does not pass
- ruby - [rspec] destroy action test does not pass
- ruby on rails - how to test that a specific element has a class name using rspec/capybara
- ruby on rails - rails rspec argumenterror occurs when the mock under test has arguments
- ruby on rails - i want to set responsestatus to 200, but it becomes 401
- ruby on rails - i want to write a rails tutorial test in rspec
Same value (
= =
) If you want to checkexpect (). to eq
Because it will be written as
I think. (I'm sorry if it doesn't work