Created
August 17, 2012 22:32
-
-
Save adamgotterer/3383269 to your computer and use it in GitHub Desktop.
Grape helper mock example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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