milkcocoa / grape-jbuilder

Use Jbuilder with Grape
MIT License
49 stars 18 forks source link

View paths inconsistent for view/controller RSpec tests #7

Closed bschaeffer closed 9 years ago

bschaeffer commented 9 years ago

Take a simple template views/api/posts.jbuilder:

json.posts do
  json.array! @posts do |post|
    json.partial! 'post', post: post
  end
end

And a structure like this:

views/
- api/
  - _post.jbuilder
  - posts.jbuilder

I get the following error in my views specs:

ActionView::Template::Error:
  Missing partial /_post, views/api/_post ... Searched in:
    * "/path/to/app/views"

But my controller specs render everything correctly without raising the template error. Seems like an error to have the second potential lookup start with the views namespace.

Not sure if this is grape, jbuilder, or grape-jbuilder, just assumed it was this library because it seems like you are setting up the render paths.

Or is this something I did?

bschaeffer commented 9 years ago

Not really sure whats happening, but calling view.lookup_context.prefixes << 'api' fixes my issue.