spec/omniauth/strategies/aleph_spec.rb in omniauth-aleph-0.1.3 vs spec/omniauth/strategies/aleph_spec.rb in omniauth-aleph-1.0.0
- old
+ new
@@ -4,12 +4,12 @@
context "when it's improperly configured" do
let(:config) {{ host: "host" }}
subject(:strategy) do
OmniAuth::Strategies::Aleph.new(nil, config).tap do |strategy|
- strategy.stub(:username) { aleph_username }
- strategy.stub(:password) { aleph_password }
+ allow(strategy).to receive(:username).and_return(aleph_username)
+ allow(strategy).to receive(:password).and_return(aleph_password)
end
end
describe "#request_phase" do
it 'should raise an Argument Error' do
@@ -33,62 +33,64 @@
subject(:strategy) do
# First argument is the app, which gets called with env,
# i.e. app.call(env), so fake it with a stabby lambda
OmniAuth::Strategies::Aleph.new(->(env) {}, config).tap do |strategy|
- strategy.stub(:username) { aleph_username }
- strategy.stub(:password) { aleph_password }
- strategy.stub(:env) { {} }
- strategy.stub(:fail!) { true }
+ allow(strategy).to receive(:username).and_return(aleph_username)
+ allow(strategy).to receive(:password).and_return(aleph_password)
+ allow(strategy).to receive(:env).and_return({})
+ allow(strategy).to receive(:fail!).and_return(true)
end
end
describe '#options' do
subject(:options) { strategy.options }
- it { should_not raise_error }
+ it 'should not raise an error' do
+ expect { subject }.to_not raise_error
+ end
describe'#name' do
subject { options.name }
- it { should_not be_nil }
- it { should eq("aleph") }
+ it { is_expected.to_not be_nil }
+ it { is_expected.to eq("aleph") }
end
describe '#title' do
subject { options.title }
- it { should_not be_nil }
- it { should eq("Aleph Authentication") }
+ it { is_expected.to_not be_nil }
+ it { is_expected.to eq("Aleph Authentication") }
end
describe '#scheme' do
subject { options.scheme }
- it { should_not be_nil }
- it { should eq("http") }
+ it { is_expected.to_not be_nil }
+ it { is_expected.to eq("http") }
end
describe '#host' do
subject { options.host }
- it { should_not be_nil }
- it { should eq(aleph_host) }
+ it { is_expected.to_not be_nil }
+ it { is_expected.to eq(aleph_host) }
end
describe '#port' do
subject { options.port }
- it { should_not be_nil }
- it { should be(80) }
+ it { is_expected.to_not be_nil }
+ it { is_expected.to be(80) }
end
describe '#library' do
subject { options.library }
- it { should_not be_nil }
- it { should eq(aleph_library) }
+ it { is_expected.to_not be_nil }
+ it { is_expected.to eq(aleph_library) }
end
describe '#sub_library' do
subject { options.sub_library }
- it { should_not be_nil }
- it { should eq(aleph_sub_library) }
+ it { is_expected.to_not be_nil }
+ it { is_expected.to eq(aleph_sub_library) }
end
end
describe "#request_phase" do
it 'shouldn\'t raise an error' do
@@ -97,13 +99,13 @@
end
describe "#callback_phase", vcr: { cassette_name: "valid" } do
context "when the credentials are missing" do
before(:each) do |example|
- strategy.stub(:username) { "" }
- strategy.stub(:password) { "" }
- end
+ allow(strategy).to receive(:username).and_return("")
+ allow(strategy).to receive(:password).and_return("")
+ end
it 'shouldn\'t raise an error' do
expect{ strategy.callback_phase }.not_to raise_error
end
@@ -113,18 +115,18 @@
end
end
context "when the credentials are included" do
before(:each) do
- strategy.stub(:username) { aleph_username }
- strategy.stub(:password) { aleph_password }
- end
+ allow(strategy).to receive(:username).and_return(aleph_username)
+ allow(strategy).to receive(:password).and_return(aleph_password)
+ end
it 'shouldn\'t raise an error' do
expect{ strategy.callback_phase }.not_to raise_error
end
-
+
it 'shouldn\'t fail!' do
strategy.callback_phase
expect(strategy).not_to have_received(:fail!)
end
end
@@ -234,10 +236,10 @@
post('/auth/aleph/callback', { username: aleph_username, password: aleph_password })
expect(auth_hash.uid).to eq('USERNAME')
expect(auth_hash.info.name).to eq('USERNAME, TEST-RECORD')
expect(auth_hash.info.nickname).to eq('USERNAME')
expect(auth_hash.info.email).to eq('username@library.edu')
- expect(auth_hash.info.phone).to be_nil
+ expect(auth_hash.info.phone).to be_blank
expect(auth_hash.extra.raw_info.bor_auth.z303.z303_id).to eq('USERNAME')
end
end
end
end