I am new to Rspec
. How to write controller code to connect to localhost:3000/v.json
link in Rspec
and check the title is as expected?
JSON format is {id: 1, title: "new"}
Please help!
I am new to Rspec
. How to write controller code to connect to localhost:3000/v.json
link in Rspec
and check the title is as expected?
JSON format is {id: 1, title: "new"}
Please help!
You need a functional test of your controller, that hits your action, with something like this:
@expected = {
id: 1,
title: "new"
}.to_json
# replace with action name / params as necessary, perhaps also passing "id: 1"?
get :v, format: "json"
response.body.should == @expected