Skip to content

Commit

Permalink
Add FakeIdp.reset! method to reset configuration state
Browse files Browse the repository at this point in the history
  • Loading branch information
cbortz committed Jan 4, 2019
1 parent c86c401 commit 4f9d5fa
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/fake_idp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ def self.configuration
def self.configure
yield(configuration)
end

def self.reset!
@configuration = nil
end
end
37 changes: 36 additions & 1 deletion spec/fake_idp_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "spec_helper"

describe FakeIdp do
describe "#configure" do
describe ".configure" do
context 'valid configuration' do
before do
FakeIdp.configure do |config|
Expand Down Expand Up @@ -61,4 +61,39 @@
end
end
end

describe ".reset!" do
before do
FakeIdp.configure do |config|
config.callback_url = "http://localhost.dev:3000/auth/saml/devidp/callback"
config.sso_uid = "12345"
config.username = "bobthessouser"
config.name_id = "[email protected]"
config.additional_attributes = { foo: "bar" }
end

FakeIdp.reset!
end

it "resets the callback_url" do
expect(FakeIdp.configuration.callback_url).
not_to eq("http://localhost.dev:3000/auth/saml/devidp/callback")
end

it "resets the sso_uid" do
expect(FakeIdp.configuration.sso_uid).not_to eq("12345")
end

it "resets the username" do
expect(FakeIdp.configuration.username).not_to eq("bobthessouser")
end

it "resets the name_id" do
expect(FakeIdp.configuration.name_id).not_to eq("[email protected]")
end

it "resets the additional_attributes" do
expect(FakeIdp.configuration.additional_attributes).not_to eq({ foo: "bar" })
end
end
end

0 comments on commit 4f9d5fa

Please sign in to comment.