-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MissingTemplate while testing controller action using rabl. #446
Comments
I found, that whenever there is an actual error in the view, say trying to access an attribute that doesn't exist, it would produce the missing template error. Gave me much headache before I found out about this. Maybe that's a hint. |
I'm having the same issue. I'm using: Everything works fine through a REST client or the browser, but keep getting 'Missing template' when I try and test my controllers. I've double and triple checked my templates (which do exist) and everything seems fine. Thanks. |
I was facing the same error. This worked for me it "should get recent public goals" do
end If you look at documentation of get action second parameter is format. I was missing that parameter that was causing missing template error. |
That did it! Thanks, missed that as well. |
I know it's been 3 years since this post, but i am new in rails and i'm suffering this issue. The solution "should get recent public goals" do worked fine for the index, but when i am at the update teste, the error is still there.
This is my controller
and this is my test;
Thanks |
The problem was that i didn't have any idea of where to put the param :format, after a while i found it :
Now it seems silly know where to put the param, but it wasn't so obvios for me time ago, so i will leave the comment. |
I have controller action whose output i am rendering using rabl.
Controller looks like this
class Api::V1::CategoryController < Api::ApiController
def index
@categories = Category.all()
end
end
My rabl templates are like this
show.json.rabl
object @category
attributes :id, :description
node (:pic_urls) { |category| get_category_pic_urls(category)
}
index.json.rabl
collection @categories
extends "api/v1/category/show"
When i call this controller action in browser it renders json nicely.
But when i am trying to run my rspec test it fails with error. My category_spec.rb is like
require 'spec_helper'
describe Api::V1::CategoryController do
render_views
end
This is error that i am getting
Failure/Error: get :index
ActionView::MissingTemplate:
Missing template api/v1/category/index, api/api/index, application/index with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee, :haml, :rabl]}. Searched in:
* "/Users/macuser/code/goalchi/app/views"
My question is why while running test it is not able to get this template.
i am on rails Rails 3.2.13.
Thanks
The text was updated successfully, but these errors were encountered: