Use RSpec expectation syntax

This commit is contained in:
Erik Michaels-Ober 2014-01-16 06:04:44 +01:00
parent 93fdee8b56
commit 6da9a1396c
3 changed files with 14 additions and 14 deletions

View File

@ -3,7 +3,7 @@ require 'helper'
describe OmniAuth::Builder do describe OmniAuth::Builder do
describe '#provider' do describe '#provider' do
it 'translates a symbol to a constant' do it 'translates a symbol to a constant' do
OmniAuth::Strategies.should_receive(:const_get).with('MyStrategy').and_return(Class.new) expect(OmniAuth::Strategies).to receive(:const_get).with('MyStrategy').and_return(Class.new)
OmniAuth::Builder.new(nil) do OmniAuth::Builder.new(nil) do
provider :my_strategy provider :my_strategy
end end
@ -32,7 +32,7 @@ describe OmniAuth::Builder do
it 'merges provided options in' do it 'merges provided options in' do
k = Class.new k = Class.new
b = OmniAuth::Builder.new(nil) b = OmniAuth::Builder.new(nil)
b.should_receive(:use).with(k, :foo => 'bar', :baz => 'tik') expect(b).to receive(:use).with(k, :foo => 'bar', :baz => 'tik')
b.options :foo => 'bar' b.options :foo => 'bar'
b.provider k, :baz => 'tik' b.provider k, :baz => 'tik'
@ -41,7 +41,7 @@ describe OmniAuth::Builder do
it 'adds an argument if no options are provided' do it 'adds an argument if no options are provided' do
k = Class.new k = Class.new
b = OmniAuth::Builder.new(nil) b = OmniAuth::Builder.new(nil)
b.should_receive(:use).with(k, :foo => 'bar') expect(b).to receive(:use).with(k, :foo => 'bar')
b.options :foo => 'bar' b.options :foo => 'bar'
b.provider k b.provider k

View File

@ -78,7 +78,7 @@ describe OmniAuth::Strategy do
it 'is true if options.skip_info is a callable that evaluates to truthy' do it 'is true if options.skip_info is a callable that evaluates to truthy' do
instance = ExampleStrategy.new(app, :skip_info => lambda { |uid| uid }) instance = ExampleStrategy.new(app, :skip_info => lambda { |uid| uid })
instance.should_receive(:uid).and_return(true) expect(instance).to receive(:uid).and_return(true)
expect(instance).to be_skip_info expect(instance).to be_skip_info
end end
end end
@ -174,8 +174,8 @@ describe OmniAuth::Strategy do
let(:instance) { subject.new(app) } let(:instance) { subject.new(app) }
it 'calls through to uid and info' do it 'calls through to uid and info' do
instance.should_receive :uid expect(instance).to receive(:uid)
instance.should_receive :info expect(instance).to receive(:info)
instance.auth_hash instance.auth_hash
end end
@ -221,7 +221,7 @@ describe OmniAuth::Strategy do
klass = Class.new klass = Class.new
klass.send :include, OmniAuth::Strategy klass.send :include, OmniAuth::Strategy
instance = klass.new(app) instance = klass.new(app)
instance.should_receive(:dup).and_return(instance) expect(instance).to receive(:dup).and_return(instance)
instance.call('rack.session' => {}) instance.call('rack.session' => {})
end end
end end
@ -316,7 +316,7 @@ describe OmniAuth::Strategy do
end end
it 'is set on the failure env' do it 'is set on the failure env' do
OmniAuth.config.should_receive(:on_failure).and_return(lambda { |env| env }) expect(OmniAuth.config).to receive(:on_failure).and_return(lambda { |env| env })
@options = {:failure => :forced_fail} @options = {:failure => :forced_fail}
strategy.call(make_env('/auth/test/callback', 'rack.session' => {'omniauth.origin' => '/awesome'})) strategy.call(make_env('/auth/test/callback', 'rack.session' => {'omniauth.origin' => '/awesome'}))
end end
@ -368,7 +368,7 @@ describe OmniAuth::Strategy do
context 'callback_url' do context 'callback_url' do
it 'uses the default callback_path' do it 'uses the default callback_path' do
strategy.should_receive(:full_host).and_return('http://example.com') expect(strategy).to receive(:full_host).and_return('http://example.com')
expect { strategy.call(make_env) }.to raise_error('Request Phase') expect { strategy.call(make_env) }.to raise_error('Request Phase')
@ -447,7 +447,7 @@ describe OmniAuth::Strategy do
context 'callback_url' do context 'callback_url' do
it 'uses a custom callback_path if one is provided' do it 'uses a custom callback_path if one is provided' do
@options = {:callback_path => '/radical'} @options = {:callback_path => '/radical'}
strategy.should_receive(:full_host).and_return('http://example.com') expect(strategy).to receive(:full_host).and_return('http://example.com')
expect { strategy.call(make_env('/radical')) }.to raise_error('Callback Phase') expect { strategy.call(make_env('/radical')) }.to raise_error('Callback Phase')
@ -481,7 +481,7 @@ describe OmniAuth::Strategy do
context 'callback_url' do context 'callback_url' do
it 'uses a custom prefix' do it 'uses a custom prefix' do
strategy.should_receive(:full_host).and_return('http://example.com') expect(strategy).to receive(:full_host).and_return('http://example.com')
expect { strategy.call(make_env('/wowzers/test')) }.to raise_error('Request Phase') expect { strategy.call(make_env('/wowzers/test')) }.to raise_error('Request Phase')
@ -700,7 +700,7 @@ describe OmniAuth::Strategy do
expect(strategy.full_host).to eq('http://my.host.net') expect(strategy.full_host).to eq('http://my.host.net')
end end
it 'should honor HTTP_X_FORWARDED_PROTO if present' do it 'honors HTTP_X_FORWARDED_PROTO if present' do
OmniAuth.config.full_host = nil OmniAuth.config.full_host = nil
strategy.call(make_env('/whatever', 'HTTP_X_FORWARDED_PROTO' => 'https', 'rack.url_scheme' => 'http', 'SERVER_NAME' => 'my.host.net', 'SERVER_PORT' => 443)) strategy.call(make_env('/whatever', 'HTTP_X_FORWARDED_PROTO' => 'https', 'rack.url_scheme' => 'http', 'SERVER_NAME' => 'my.host.net', 'SERVER_PORT' => 443))
expect(strategy.full_host).to eq('https://my.host.net') expect(strategy.full_host).to eq('https://my.host.net')

View File

@ -92,12 +92,12 @@ describe OmniAuth do
before do before do
OmniAuth.config.add_mock(:facebook, :uid => '12345', :info => {:name => 'Joe', :email => 'joe@example.com'}) OmniAuth.config.add_mock(:facebook, :uid => '12345', :info => {:name => 'Joe', :email => 'joe@example.com'})
end end
it 'default should be AuthHash' do it 'default is AuthHash' do
OmniAuth.configure do |config| OmniAuth.configure do |config|
expect(config.mock_auth[:default]).to be_kind_of(OmniAuth::AuthHash) expect(config.mock_auth[:default]).to be_kind_of(OmniAuth::AuthHash)
end end
end end
it 'facebook should be AuthHash' do it 'facebook is AuthHash' do
OmniAuth.configure do |config| OmniAuth.configure do |config|
expect(config.mock_auth[:facebook]).to be_kind_of(OmniAuth::AuthHash) expect(config.mock_auth[:facebook]).to be_kind_of(OmniAuth::AuthHash)
end end