title: How to write an RSpec test for a simple PUT update?
body: <p>I'm trying to solidify my understanding of rails and the BDD workflow, so I wanted to start small by creating one of those mini-blogs, but with rspec. Right now I have an ArticlesController and Article model, and associated rspec files. Article is very simple, has just title:string and content:text, and the ArticlesController is RESTful - although I hand wrote the MCV for Article, it's basically the same as if I used a scaffold to create it.</p>
  
  <p>However I don't really know what I'm doing when it comes to writing a test in rspec for the PUT update. I'm using Factory Girl to create the article object, and so far my code looks like:</p>
  
  <pre><code>#factories.rb
  FactoryGirl.define do
    factory :article do
    title "a title"
    content "hello world"
  end
  
  #articles_controller_spec.rb
  before(:each) do
    @article = Factory(:article)
  end
  
  describe "PUT 'update/:id'" do
    it "allows an article to be updated" do
      @attr = { :title =&gt; "new title", :content =&gt; "new content" }
      put :update, :id =&gt; @article.id, :article =&gt; @attr
      response.should be_successful
    end
  end
  </code></pre>
  
  <p>However I keep getting:</p>
  
  <pre><code>Failures:
  1) ArticlesController PUT 'update/:id' allows an article to be updated
     Failure/Error: response.should be_successful
       expected successful? to return true, got false
  </code></pre>
  
  <p>What am I doing wrong? And am I using the right tools? When I run my test server, New, Edit, Destroy all work as I would expect them to, so I'm guessing this is a problem with my understanding of RSpec. Let me know if I'm wrong - thanks!</p>