title: Cucumber/RSpec testing of improbable errors
body: <p>I've got a problem testing the following controller code:</p>
  
  <pre><code>def publish
    if @article.publish
      flash[:notice] = "Article '#{@article.title}' was published."
    else
      # This is not tested
      flash[:error] = "Error publishing article."
    end
    redirect_to :action =&gt; :index
  end
  </code></pre>
  
  <p>Where the function publish looks like that:</p>
  
  <pre><code>def publish
    self.toggle!(:is_published)
  end
  </code></pre>
  
  <p>Function <code>toggle!</code> is atomic and in theory will fail only when there is a problem with database (in practice I can find number of scenarios where the error should be detected because someone breaks the publish method implementation). How can I test in Cucumber that the correct message is shown in case of error? </p>