Sha256: 4c34317e1787945c4d00410b7f120c5fe94e548c1eba6bef0a2342147ef37eeb
Contents?: true
Size: 955 Bytes
Versions: 3
Compression:
Stored size: 955 Bytes
Contents
# frozen_string_literal: true describe Grape::API::Helpers do module NestedHelpersSpec module HelperMethods extend Grape::API::Helpers def current_user @current_user ||= params[:current_user] end end class Nested < Grape::API resource :level1 do helpers HelperMethods get do current_user end resource :level2 do get do current_user end end end end class Main < Grape::API mount Nested end end subject do NestedHelpersSpec::Main end def app subject end it 'can access helpers from a mounted resource' do get '/level1', current_user: 'hello' expect(last_response.body).to eq('hello') end it 'can access helpers from a mounted resource in a nested resource' do get '/level1/level2', current_user: 'world' expect(last_response.body).to eq('world') end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
grape-1.8.0 | spec/grape/api/nested_helpers_spec.rb |
grape-1.7.1 | spec/grape/api/nested_helpers_spec.rb |
grape-1.7.0 | spec/grape/api/nested_helpers_spec.rb |