Sha256: 0d6b77e1cef134f7e13c7d8457f2a647e5cad5379d5e1ddfc8ad9c67a45a1fb9
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
RSpec.describe Rails::Auth::Principals do describe "#principals" do let(:example_type) { "example" } let(:example_principals) { { example_type => double(:principal) } } let(:example_env) do env_for(:get, "/").tap do |env| env[Rails::Auth::PRINCIPALS_ENV_KEY] = example_principals end end it "extracts principals from Rack environments" do expect(Rails::Auth.principals(example_env)).to eq example_principals end end describe "#add_principal" do let(:example_type) { "example" } let(:example_principal) { double(:principal) } let(:example_env) { env_for(:get, "/") } it "adds principals to a Rack environment" do expect(Rails::Auth.principals(example_env)[example_type]).to be_nil Rails::Auth.add_principal(example_env, example_type, example_principal) expect(Rails::Auth.principals(example_env)[example_type]).to eq example_principal end it "raises ArgumentError if the same type of principal is added twice" do Rails::Auth.add_principal(example_env, example_type, example_principal) expect do Rails::Auth.add_principal(example_env, example_type, example_principal) end.to raise_error(ArgumentError) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails-auth-0.0.1 | spec/rails/auth/principals_spec.rb |