title: Make sure JSON response just contains X keys with rspec
body: <p>I have the following rspec request test:</p>
  
  <pre><code>describe "Order Processing Statuses API" do
    # index
    let(:user_with_api) { FactoryGirl.create(:user_with_api) }
    it 'sends a list of order statuses' do
      FactoryGirl.create_list(:order_processing_status, 2)
  
      get '/api/v1/order_statuses', nil, 'HTTP_AUTHORIZATION'=&gt;"Token token=\"#{user_with_api.api_keys.first.access_token}\"" 
  
      expect(response).to be_success            
      expect(json.length).to eq(2) 
    end
  end
  </code></pre>
  
  <p>Where json is defined by this helper:</p>
  
  <pre><code>module Requests
    module JsonHelpers
      def json
        @json ||= JSON.parse(response.body)
      end
    end
  end
  </code></pre>
  
  <p>How do I make sure that each object in the JSON array, just have the keys that my API wants to expose? So, in my controller I will have something like this:</p>
  
  <pre><code>render @json, only: [:id, :name]
  </code></pre>
  
  <p>How do I make sure that each object of the response will just have those attributes? Taking into account that when defining the object with the Factory, more attributes are added that the ones that are exposed publicly.</p>