Commit 0df989ba authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add specs for token authenticable strategy factory method

parent 621071ca
...@@ -45,11 +45,11 @@ module TokenAuthenticatableStrategies ...@@ -45,11 +45,11 @@ module TokenAuthenticatableStrategies
def self.fabricate(instance, field, options) def self.fabricate(instance, field, options)
if options[:digest] if options[:digest]
TokenAuthenticatableStrategies::Digest.new(instance, field, options) TokenAuthenticatableStrategies::Digest.new(instance, field, options)
elsif options[:encrypted] elsif options[:encrypted]
TokenAuthenticatableStrategies::Encrypted.new(instance, field, options) TokenAuthenticatableStrategies::Encrypted.new(instance, field, options)
else else
TokenAuthenticatableStrategies::Insecure.new(instance, field, options) TokenAuthenticatableStrategies::Insecure.new(instance, field, options)
end end
end end
......
require 'spec_helper'
describe TokenAuthenticatableStrategies::Base do
let(:instance) { double(:instance) }
let(:field) { double(:field) }
describe '.fabricate' do
context 'when digest stragegy is specified' do
it 'fabricates digest strategy object' do
strategy = described_class.fabricate(instance, field, digest: true)
expect(strategy).to be_a TokenAuthenticatableStrategies::Digest
end
end
context 'when encrypted strategy is specified' do
it 'fabricates encrypted strategy object' do
strategy = described_class.fabricate(instance, field, encrypted: true)
expect(strategy).to be_a TokenAuthenticatableStrategies::Encrypted
end
end
context 'when no strategy is specified' do
it 'fabricates insecure strategy object' do
strategy = described_class.fabricate(instance, field, something: true)
expect(strategy).to be_a TokenAuthenticatableStrategies::Insecure
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment