Skip to content

Commit eea830a

Browse files
committed
Use instance doubles and proper stubbed objects
1 parent a55f591 commit eea830a

File tree

4 files changed

+16
-27
lines changed

4 files changed

+16
-27
lines changed

.rubocop_todo.yml

-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/omniauth/strategies/cas/logout_request_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
RSpec.describe OmniAuth::Strategies::CAS::LogoutRequest do
66
subject(:call) { described_class.new(strategy, request).call(options) }
77

8-
let(:strategy) { double('strategy') }
8+
let(:strategy) { instance_double(OmniAuth::Strategies::CAS) }
99
let(:env) do
1010
{ 'rack.input' => StringIO.new('', 'r') }
1111
end
12-
let(:request) { double('request', params: params, env: env) }
12+
let(:request) { instance_double(Rack::Request, params: params, env: env) }
1313
let(:params) { { 'url' => url, 'logoutRequest' => logout_request_xml } }
1414
let(:url) { 'http://example.org/signed_in' }
1515
let(:logout_request_xml) do

spec/omniauth/strategies/cas/service_ticket_validator_spec.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
RSpec.describe OmniAuth::Strategies::CAS::ServiceTicketValidator do
66
let(:strategy) do
7-
double('strategy',
8-
service_validate_url: 'https://example.org/serviceValidate')
7+
instance_double(OmniAuth::Strategies::CAS, service_validate_url: 'https://example.org/serviceValidate')
98
end
109
let(:provider_options) do
11-
double('provider_options',
12-
disable_ssl_verification?: false,
13-
merge_multivalued_attributes: false,
14-
ca_path: '/etc/ssl/certsZOMG')
10+
OmniAuth::Strategy::Options.new(
11+
disable_ssl_verification: false,
12+
merge_multivalued_attributes: false,
13+
ca_path: '/etc/ssl/certsZOMG'
14+
)
1515
end
1616
let(:validator) do
1717
described_class.new(strategy, provider_options, '/foo', nil)
@@ -30,7 +30,10 @@
3030
end
3131

3232
it 'uses the configured CA path' do
33+
allow(provider_options).to receive(:ca_path)
34+
3335
call
36+
3437
expect(provider_options).to have_received :ca_path
3538
end
3639
end
@@ -58,10 +61,7 @@
5861

5962
context 'when merging multivalued attributes' do
6063
let(:provider_options) do
61-
double('provider_options',
62-
disable_ssl_verification?: false,
63-
merge_multivalued_attributes: true,
64-
ca_path: '/etc/ssl/certsZOMG')
64+
OmniAuth::Strategy::Options.new(merge_multivalued_attributes: true)
6565
end
6666

6767
it 'parses multivalued user info from the response' do

spec/omniauth/strategies/cas_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@
268268
XML
269269
end
270270

271-
let(:logout_request) { double('logout_request', call: [200, {}, 'OK']) }
271+
let(:logout_request) { instance_double(MyCasProvider::LogoutRequest, call: [200, {}, 'OK']) }
272272

273273
before do
274-
allow_any_instance_of(MyCasProvider)
275-
.to receive(:logout_request_service)
276-
.and_return double('LogoutRequest', new: logout_request)
274+
allow(MyCasProvider::LogoutRequest)
275+
.to receive(:new)
276+
.and_return logout_request
277277

278278
sso_logout_request
279279
end

0 commit comments

Comments
 (0)