A quick fix to the RuntimeError: can't modify frozen Array
is to run rails c
which will give you a better error so you can fix the problem.
Category: RSpec
I haven’t posted in quite a while. Been working with a lot of RSpec request testing for controllers, graphql, and active admin. (Never forget the S in RSpec is capitalized – that would have saved me a lot of pain!!)
My current trouble was sending an attribute that required a json value to an active admin create route via RSpec Request. I tried a whole bunch of things, but the solution is sooo simple, (too simple for the time spent on it) that I had to post it in case I needed to look up what I did again.
I just had to add .to_json
on that specific attribute requiring json.
let(:valid_attributes) do attributes_for( :model, content: {"key"=>"value"}.to_json ) end
I hope this helps someone 🙂
I need to start posting more, just when you find the solution after debugging for so many hours it feels too simple to post about. Like I should have known that already! But I think we all have those moments!
Happy Programming 🙂