Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4615

How to fix "no implicit conversion of String into Hash"

$
0
0

I am trying to run a test with RSpec but it always returns the same error:

DevicesController#update when user is a manager must update any device     Failure/Error: put device_path device_id, params: params, headers: { 'Content-Type': 'application/vnd.api+json' }     TypeError:       no implicit conversion of String into Hash

My function with the request params:

def update_params(device, device_id)  {    data: {      id: device.id,      type: 'device',      attributes: {        device_id: device_id       }    }  }.to_jsonend

My test using factories:

context 'when user is a manager' do  let(:user) { create(:manager).account }  let(:firebase_token) { Faker::Crypto.sha1 }  let(:device_id) { physical_device.id }  let(:params) { update_params(physical_device, firebase_token) }  it 'must update any device' do    expect(Device.find(device_id).device_id).to eq(firebase_token)  endend

The request OS update device:

put device_path device_id, params: params, headers: { 'Content-Type': 'application/vnd.api+json' }

Viewing all articles
Browse latest Browse all 4615

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>