spec/grape/middleware/auth/oauth2_spec.rb in grape-0.7.0 vs spec/grape/middleware/auth/oauth2_spec.rb in grape-0.8.0
- old
+ new
@@ -31,11 +31,11 @@
context 'with the token in the query string' do
context 'and a valid token' do
before { get '/awesome?access_token=g123' }
it 'sets env["api.token"]' do
- last_response.body.should == 'g123'
+ expect(last_response.body).to eq('g123')
end
end
context 'and an invalid token' do
before do
@@ -43,15 +43,15 @@
get '/awesome?access_token=b123'
end
end
it 'throws an error' do
- @err[:status].should == 401
+ expect(@err[:status]).to eq(401)
end
it 'sets the WWW-Authenticate header in the response' do
- @err[:headers]['WWW-Authenticate'].should == "OAuth realm='OAuth API', error='invalid_grant'"
+ expect(@err[:headers]['WWW-Authenticate']).to eq("OAuth realm='OAuth API', error='invalid_grant'")
end
end
end
context 'with an expired token' do
@@ -60,37 +60,37 @@
get '/awesome?access_token=e123'
end
end
it 'throws an error' do
- @err[:status].should == 401
+ expect(@err[:status]).to eq(401)
end
it 'sets the WWW-Authenticate header in the response to error' do
- @err[:headers]['WWW-Authenticate'].should == "OAuth realm='OAuth API', error='invalid_grant'"
+ expect(@err[:headers]['WWW-Authenticate']).to eq("OAuth realm='OAuth API', error='invalid_grant'")
end
end
%w(HTTP_AUTHORIZATION X_HTTP_AUTHORIZATION X-HTTP_AUTHORIZATION REDIRECT_X_HTTP_AUTHORIZATION).each do |head|
context "with the token in the #{head} header" do
before do
get '/awesome', {}, head => 'OAuth g123'
end
it 'sets env["api.token"]' do
- last_response.body.should == 'g123'
+ expect(last_response.body).to eq('g123')
end
end
end
context 'with the token in the POST body' do
before do
post '/awesome', 'access_token' => 'g123'
end
it 'sets env["api.token"]' do
- last_response.body.should == 'g123'
+ expect(last_response.body).to eq('g123')
end
end
context 'when accessing something outside its scope' do
before do
@@ -98,15 +98,15 @@
get '/forbidden?access_token=g123'
end
end
it 'throws an error' do
- @err[:status].should == 403
+ expect(@err[:status]).to eq(403)
end
it 'sets the WWW-Authenticate header in the response to error' do
- @err[:headers]['WWW-Authenticate'].should == "OAuth realm='OAuth API', error='insufficient_scope'"
+ expect(@err[:headers]['WWW-Authenticate']).to eq("OAuth realm='OAuth API', error='insufficient_scope'")
end
end
context 'when authorization is not required' do
def app
@@ -118,18 +118,18 @@
context 'with no token' do
before { post '/awesome' }
it 'succeeds anyway' do
- last_response.status.should == 200
+ expect(last_response.status).to eq(200)
end
end
context 'with a valid token' do
before { get '/awesome?access_token=g123' }
it 'sets env["api.token"]' do
- last_response.body.should == 'g123'
+ expect(last_response.body).to eq('g123')
end
end
end
end