nesquena / rabl

General ruby templating with json, bson, xml, plist and msgpack support
http://blog.codepath.com/2011/06/27/building-a-platform-api-on-rails/
MIT License
3.64k stars 333 forks source link

Rspec renders rabl as string instead of json #716

Closed zauzaj closed 5 years ago

zauzaj commented 6 years ago

Hi all,

I'm doing rails engine and I have controller that has to render json as response. Everything works as expected when I do Curl but with Rspec it renders just string instead of compiled json.

Here it is:

describe SyncController, type: :controller do
  render_views
  .....
  it "returns last event unique_identifier" do
    get :index, { use_route: :my_engine, format: :json, event_id: @v1.unique_identifier }
    .......
  end  
end

My response.body here is:

"collection @response_body => :events\n\nnode(:event_id) { |n| n['unique_identifier'] }\n\nextends \"sync/consultation_info\"\nextends \"sync/patient_info\""

So based on this, it seems it lookup into rabl file but it doesn't read it properly.

This is really annoying but I really don't know what is trick.

Any help would be appreciated. Thanks