Is there a proper way to edit a variable created by :let and call it?
describe "#create" do
let(:animal_payload) {
{
"data": {
......
"animal_type": {
"data": {
"id": 1,
"type": "sea",
}
},
}
}
}
let(:land_animal_payload) {animal_payload}
:land_animal_payload["data"]["animal_type"] = {data:[{"id":1, "type":land}]}
context "when animal is type land" do
subject { post :create, params: land_animal_payload }
it "should create a land animal" do
....
end
end
I have a very large payload called animal_payload. I just want to change the field animal_type and call a post on it. However, when I call this: :land_animal_payload["data"]["animal_type"] = {data:[{"id":1, "type":land}]}
I get:
`undefined method `[]' for nil:NilClass
How can I use the same payload but change one of the fields slightly so that I can call it?