Sha256: 81936b95ba8ae18bf4c6ae0db16386a0c73b55f0661b620cf6615fcf636318f0

Contents?: true

Size: 752 Bytes

Versions: 2

Compression:

Stored size: 752 Bytes

Contents

require 'spec_helper'

describe "Grape::Rabl partials" do
  subject do
    Class.new(Grape::API)
  end

  before do
    subject.format :json
    subject.formatter :json, Grape::Formatter::Rabl
    subject.before { env["api.tilt.root"] = "#{File.dirname(__FILE__)}/views" }
  end

  def app
    subject
  end

  it "proper render partials" do
    subject.get("/home", :rabl => "project") do
      @author   = OpenStruct.new(:author => "LTe")
      @type     = OpenStruct.new(:type => "paper")
      @project  = OpenStruct.new(:name => "First", :type => @type, :author => @author)
    end

    get("/home")
    last_response.body.should ==
      "{\"project\":{\"name\":\"First\",\"info\":{\"type\":\"paper\"},\"author\":{\"author\":\"LTe\"}}}"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
grape-rabl-0.2.2 spec/grape_rabl_partials_spec.rb
grape-rabl-0.2.1 spec/grape_rabl_partials_spec.rb