Sha256: bf5f867c30e85a664b80c0b4cc32d0a7f9aec147d23f35a1e6a423a1079c187f
Contents?: true
Size: 2 KB
Versions: 2
Compression:
Stored size: 2 KB
Contents
require 'spec_helper' describe OmniAuth::Strategies::Developer do let(:app){ Rack::Builder.new do |b| b.use Rack::Session::Cookie b.use OmniAuth::Strategies::Developer b.run lambda{|env| [200, {}, ['Not Found']]} end.to_app } context "request phase" do before(:each){ get '/auth/developer' } it "displays a form" do expect(last_response.status).to eq(200) expect(last_response.body).to be_include("<form") end it "has the callback as the action for the form" do expect(last_response.body).to be_include("action='/auth/developer/callback'") end it "has a text field for each of the fields" do expect(last_response.body.scan('<input').size).to eq(2) end end context "callback phase" do let(:auth_hash){ last_request.env['omniauth.auth'] } context "with default options" do before do post '/auth/developer/callback', :name => 'Example User', :email => 'user@example.com' end it "sets the name in the auth hash" do expect(auth_hash.info.name).to eq('Example User') end it "sets the email in the auth hash" do expect(auth_hash.info.email).to eq('user@example.com') end it "sets the uid to the email" do expect(auth_hash.uid).to eq('user@example.com') end end context "with custom options" do let(:app){ Rack::Builder.new do |b| b.use Rack::Session::Cookie b.use OmniAuth::Strategies::Developer, :fields => [:first_name, :last_name], :uid_field => :last_name b.run lambda{|env| [200, {}, ['Not Found']]} end.to_app } before do @options = {:uid_field => :last_name, :fields => [:first_name, :last_name]} post '/auth/developer/callback', :first_name => 'Example', :last_name => 'User' end it "sets info fields properly" do expect(auth_hash.info.name).to eq('Example User') end it "sets the uid properly" do expect(auth_hash.uid).to eq('User') end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
omniauth-1.1.3 | spec/omniauth/strategies/developer_spec.rb |
omniauth-1.1.2 | spec/omniauth/strategies/developer_spec.rb |