title: ActionController::UnknownFormat with rspec and post request
body: <p>I'm trying to do some integration tests with rspec on rails 4 but I alway get a "ActionController::UnknownFormat" exception when running the tests.</p>
  
  <p>I tried two different ways:</p>
  
  <pre><code>Failure/Error: post sensors_path, sensor: @sensor_attributes.to_json
  ActionController::UnknownFormat:
      ActionController::UnknownFormat
  
  
  Failure/Error: post sensors_path, sensor: @sensor_attributes, format: :js
  ActionController::UnknownFormat:
      ActionController::UnknownFormat
  </code></pre>
  
  <p>Here is the rspec code:</p>
  
  <pre><code>it "should change the number of sensors" do
      lambda do
          post sensors_path, sensor: @sensor_attributes.to_json 
          end.should change(Sensor, :count).by(1)
      end
  
  it "should be successful" do
      post sensors_path, sensor: @sensor_attributes, format: :js
      response.should be_success
  end
  </code></pre>
  
  <p>And this is the create statement of the controller:</p>
  
  <pre><code>def create
      respond_to do |format|
          format.json do
              @sensor = Sensor.new(params["sensor"])
              @sensor.uuid = SecureRandom.uuid
  
              @sensor.save
  
              render nothing: true
          end
      end
  end
  </code></pre>
  
  <p>And the sensor_attributes:</p>
  
  <pre><code>before do
      @sensor_attributes = { name: "Testname", description: "This is a Test-Description." }
  end
  </code></pre>
  
  <p>And the routes:</p>
  
  <pre><code>resources :sensors
  </code></pre>
  
  <p>Any idea what went wrong?</p>