I'm developing an API using Ruby on Rails. I've created some specs for posts_controller.rb
and I'm having this error while running the specs
SystemStackError: stack level too deep
./app/controllers/api/v1/posts_controller.rb:10:in `show'
./spec/controllers/api/v1/posts_controller_spec.rb:8:in `block (3 levels) in <top (required)>'
This is my posts_controller_spec.rb
require 'spec_helper'
describe API::V1::PostsController do
describe "GET #show" do
before(:each) do
@post = FactoryGirl.create :post
get :show, id: @post.id
end
it "returns the information about a post on a hash" do
post_response = json_response[:post]
expect(post_response[:description]).to eql @post.description
end
it "has the user as a embeded object" do
post_response = json_response[:post]
expect(post_response[:user][:email]).to eql @post.user.email
end
it { expect(response.status).to eql 200 }
end
.
.
.
And this is my posts_controller.rb
class API::V1::PostsController < ApplicationController
respond_to :json
def show
respond_with Post.find(params[:id])
end
.
.
.
Anybody have ideas to solve this problem ?
Aucun commentaire:
Enregistrer un commentaire