Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Commit

Permalink
Update controller specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jessie A Young committed Jun 6, 2016
1 parent 1971489 commit c7fdd7c
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
require 'rails_helper'

RSpec.describe ApplicationController, controller: true do
describe ApplicationController do
describe "authenticator" do
before do
allow(controller).to receive(:format).and_return(format)
end

context 'when the controller receives a web request' do
let(:format) { double('format', "html?" => true, "json?" => false) }

it 'should return an instance of WebAuthenticator' do
expect(controller.send(:authenticator)).to be_a(WebAuthenticator)
context 'API request' do
it 'should return an instance of ApiAuthenticator' do
format = double('format', "json?" => true)
request = double('request', format: format)
allow(controller).to receive(:request).and_return(request)
expect(controller.send(:authenticator)).to be_a(ApiAuthenticator)
end
end

context 'when the controller receives an API request' do
let(:format) { double('format', "html?" => false, "json?" => true) }

it 'should return an instance of ApiAuthenticator' do
context 'non-API request' do
it 'should return an instance of WebAuthenticator' do
format = double('format', "json?" => false)
request = double('request', format: format)
allow(controller).to receive(:request).and_return(request)
expect(controller.send(:authenticator)).to be_a(WebAuthenticator)
end
end
Expand Down

0 comments on commit c7fdd7c

Please sign in to comment.