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
    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
          is_expected.to respond_with (: redirect)
          is_expected.to redirect_to (articles_path)
          expect (assigns [: article] .persisted?). To be_truthy
          is_expected.to set_flash [: notice]
            .to (I18n.t ('label.create_success', model: Article.model_name.human))
  • Answer # 1

    Same value (= =) If you want to check

    expect (). to eq

    Because it will be written as

    expect (article_params.title) .to eq assigns [: article] .title

    I think. (I'm sorry if it doesn't work