Skip to content

Instantly share code, notes, and snippets.

@adamgotterer
Created August 17, 2012 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamgotterer/3383269 to your computer and use it in GitHub Desktop.
Save adamgotterer/3383269 to your computer and use it in GitHub Desktop.
Grape helper mock example
require 'spec_helper'
require 'myapi'
describe API::MyAPI do
include Rack::Test::Methods
def app
API::MyAPI
end
subject { Class.new(API::MyAPI) }
shared_context 'authorized' do
before do
subject.helpers do
def logged_in?
true
end
end
end
end
context 'authorized' do
include_context 'authorized'
it 'checks if user is authorized' do
subject.get('/auth') do
logged_in?
end
get '/auth'
last_response.body.should be_true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment