title: rails 4.1 from rails 4 in action and rspec
body: <p>I'm trying to learn <code>rails 4.1</code> from <code>rails 4</code> in action book, I've got to chapter 13, in this chapter defined <code>API for JSON and XML</code>.</p>
  
  <p>It defined a controller like this :  </p>
  
  <pre><code>class Api::V1::ProjectsController &lt; Api::V1::BaseController  
    def index  
       respond_with(Project.for(current_user).all)  
    end  
    def create  
      project = Project.new project_params  
      if project.save  
        respond_with(project, :location =&gt; api_v1_project_path(project))  
      else  
        respond_with(errors: project.errors.messages)  
      end  
    end  
    private  
    def project_params  
      params.require(:project).permit(:name)  
    end  
  end  
  </code></pre>
  
  <p>And a rspec test like this :  </p>
  
  <pre><code>it "unsuccessful JSON" do  
    post "#{url}.json", :token =&gt; token, :project =&gt; {}  
    expect(last_response.status).to eql(422)  
    errors = {"errors" =&gt; { "name" =&gt; ["can't be blank"]}}.to_json  
    expect(last_response.body).to eql(errors)  
  end  
  </code></pre>
  
  <p>when I run the test, I get these results :  </p>
  
  <blockquote>
    <p>ActionController::ParameterMissing: param is missing or the value is
    empty: project</p>
  </blockquote>
  
  <p>I know, it's because of strong parameters.</p>