# Specificaties schrijven voor put naar een aangepast pad/model

**URL:** <https://meta.discourse.org/t/writing-specs-for-put-to-a-custom-path-model/168653>\
**Category:** Development\
**Created:** [29 oktober 2020 om 16:22 UTC](https://meta.discourse.org/t/writing-specs-for-put-to-a-custom-path-model/168653 "2020-10-29T16:22:11Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [29 oktober 2020 om 16:22 UTC](https://meta.discourse.org/t/writing-specs-for-put-to-a-custom-path-model/168653/1 "2020-10-29T16:22:11Z")

</div>

I’m working on a plugin that adds a model. I am trying to write specs that test that the model (and controller?) are behaving as expected.

This code in an ansible library, is successfully `PUT`ting to this path and updating a field in the model/record:

```python
    headers = {
        'Api-Key': discourse_api_key,
        'Api-Username': discourse_api_username,
    }

    payload = {
        "server[request_status]": status
    }
    url = "%spfaffmanager/servers/%s" % (discourse_url, server_id)

    # raise Exception(url) 
    result = requests.put(url, data=payload, headers=headers)

```

This is the spec that I am trying to write that tests updates to that path. I’m confused because I have a zillion `puts` in the controller and none of them are printing, though `puts` in the model (e.g., in a function called by `before_save` ) are showing up in the stuff I see in the `rake autospec`.

My best guess is that I’m screwing up the

```ruby
# frozen_string_literal: true
require 'rails_helper'

describe Pfaffmanager::ServersController do
  fab!(:user) { Fabricate(:user) }
  fab!(:admin) { Fabricate(:admin) }
  fab!(:another_user) { Fabricate(:user) }
  fab!(:trust_level_2) { Fabricate(:user, trust_level: TrustLevel[2]) }
  before do
    Jobs.run_immediately!
  end

  it 'can update status' do
    request_status = 'new status'
    sign_in(admin)
    s=Pfaffmanager::Server.createServerFromParams(user_id: user.id,
        hostname: 'bogus.invalid' , request_status: 'not updated')
    puts "can update status created server id: #{s.id}"
    params = {server: {request_status: request_status}}
    
    expect {
        put "/pfaffmanager/servers/#{s.id}", params: params
    }.to change { s.request_status }
    expect(response.status).to eq(200)
    expect(s.request_status).to eq('new status')
  end
end

```

I spent pretty much all day on this yesterday and would appreciate any hints on solutions or techniques for debugging.

---

_[View the full topic](https://meta.discourse.org/t/writing-specs-for-put-to-a-custom-path-model/168653)._
