I have simple controller:
class CreditLogsController < BaseController
def show
@account = Account.find_by_email(Base64.urlsafe_decode64(params[:id]))
end
end
and here is the spec for it:
require 'rails_helper'
describe CreditLogsController, type: :controller do
describe 'GET #show' do
it 'responds with 200' do
create(:account)
get :show, params: {id: Base64.urlsafe_encode64('[email protected]')}, format: :html
puts "############# #{controller.instance_variable_get(:account)}"
expect(assigns(:account)).to eql('[email protected]')
end
end
end
The problems is that account in spec is always nil, in coverage file code from controller which assigns value to @account is showed as not covered and controller.instance_variable_get(:account) raises an error:
`account' is not allowed as an instance variable name.
I have similar code in other spec and is working ok, so what am I doing wrong?
@accountwith a string'[email protected]'? It should beexpect(assigns(:account).email).to eql('[email protected]')