title: How to write a test case using rspec for a notice message
body: <p>In my application I have a topic controller and I need to write a test case for creating a new topic. when a new topic is created it will be redirected to the show page of the newly created topic and a notice will be displayed "Topic was created successfully!". I need to write a test case for checking the displayed notice is correct or not using rspec.I have the topic controller:</p>
  
  <pre><code> def create
  @topic = Topic.new(topic_params)
  if (@topic.save)
    redirect_to @topic, :notice =&gt; 'Topic was created successfully!'
  else
    render :action =&gt; 'new'
  end
  end
  </code></pre>
  
  <p>TopicController spec:</p>
  
  <pre><code>it "should create new Topic and renders show" do
      expect {
        post :create,params:{ topic:{topicname: "Tech"} }
      }.to change(Topic,:count).by(1)
      expect(response).to redirect_to(topic_path(id: 1))
     /// expect().to include("Topic was created successfully!")
    end
  </code></pre>
  
  <p>Already I have written test cases for redirecting to show page. But I am stuck with the checking the notice that I have mentioned in a comment in my code.</p>