Skip to content

Commit 1432605

Browse files
authored
Merge pull request #114 from appropriate/rspec-cleanup
chore: Clean up RSpec output
2 parents f6f9b97 + 653401b commit 1432605

File tree

2 files changed

+34
-30
lines changed

2 files changed

+34
-30
lines changed

spec/omniauth/strategies/saml_spec.rb

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ def post_xml(xml=:example_response)
3939
end
4040

4141
it 'should get authentication page' do
42-
last_response.should be_redirect
43-
last_response.location.should match /https:\/\/idp.sso.example.com\/signon\/29490/
44-
last_response.location.should match /\?SAMLRequest=/
45-
last_response.location.should_not match /mapped_param_key/
46-
last_response.location.should_not match /original_param_key/
42+
expect(last_response).to be_redirect
43+
expect(last_response.location).to match /https:\/\/idp.sso.example.com\/signon\/29490/
44+
expect(last_response.location).to match /\?SAMLRequest=/
45+
expect(last_response.location).not_to match /mapped_param_key/
46+
expect(last_response.location).not_to match /original_param_key/
4747
end
4848
end
4949

@@ -53,11 +53,11 @@ def post_xml(xml=:example_response)
5353
end
5454

5555
it 'should get authentication page' do
56-
last_response.should be_redirect
57-
last_response.location.should match /https:\/\/idp.sso.example.com\/signon\/29490/
58-
last_response.location.should match /\?SAMLRequest=/
59-
last_response.location.should match /\&mapped_param_key=original_param_value/
60-
last_response.location.should_not match /original_param_key/
56+
expect(last_response).to be_redirect
57+
expect(last_response.location).to match /https:\/\/idp.sso.example.com\/signon\/29490/
58+
expect(last_response.location).to match /\?SAMLRequest=/
59+
expect(last_response.location).to match /\&mapped_param_key=original_param_value/
60+
expect(last_response.location).not_to match /original_param_key/
6161
end
6262
end
6363

@@ -71,17 +71,17 @@ def post_xml(xml=:example_response)
7171
%w(foo.example.com bar.example.com).each do |host|
7272
get "https://#{host}/auth/saml"
7373

74-
last_response.should be_redirect
74+
expect(last_response).to be_redirect
7575

7676
location = URI.parse(last_response.location)
7777
query = Rack::Utils.parse_query location.query
78-
query.should have_key('SAMLRequest')
78+
expect(query).to have_key('SAMLRequest')
7979

8080
request = REXML::Document.new(Base64.decode64(query['SAMLRequest']))
81-
request.root.should_not be_nil
81+
expect(request.root).not_to be_nil
8282

8383
acs = request.root.attributes.get_attribute('AssertionConsumerServiceURL')
84-
acs.to_s.should == "https://#{host}/auth/saml/callback"
84+
expect(acs.to_s).to eq "https://#{host}/auth/saml/callback"
8585
end
8686
end
8787
end
@@ -93,7 +93,7 @@ def post_xml(xml=:example_response)
9393
let(:xml) { :example_response }
9494

9595
before :each do
96-
Time.stub(:now).and_return(Time.utc(2012, 11, 8, 20, 40, 00))
96+
allow(Time).to receive(:now).and_return(Time.utc(2012, 11, 8, 20, 40, 00))
9797
end
9898

9999
context "when the response is valid" do
@@ -102,21 +102,21 @@ def post_xml(xml=:example_response)
102102
end
103103

104104
it "should set the uid to the nameID in the SAML response" do
105-
auth_hash['uid'].should == '_1f6fcf6be5e13b08b1e3610e7ff59f205fbd814f23'
105+
expect(auth_hash['uid']).to eq '_1f6fcf6be5e13b08b1e3610e7ff59f205fbd814f23'
106106
end
107107

108108
it "should set the raw info to all attributes" do
109-
auth_hash['extra']['raw_info'].all.to_hash.should == {
109+
expect(auth_hash['extra']['raw_info'].all.to_hash).to eq(
110110
'first_name' => ['Rajiv'],
111111
'last_name' => ['Manglani'],
112112
'email' => ['user@example.com'],
113113
'company_name' => ['Example Company'],
114114
'fingerprint' => saml_options[:idp_cert_fingerprint]
115-
}
115+
)
116116
end
117117

118118
it "should set the response_object to the response object from ruby_saml response" do
119-
auth_hash['extra']['response_object'].should be_kind_of(OneLogin::RubySaml::Response)
119+
expect(auth_hash['extra']['response_object']).to be_kind_of(OneLogin::RubySaml::Response)
120120
end
121121
end
122122

@@ -128,17 +128,17 @@ def post_xml(xml=:example_response)
128128
end
129129

130130
it "should set the uid to the nameID in the SAML response" do
131-
auth_hash['uid'].should == '_1f6fcf6be5e13b08b1e3610e7ff59f205fbd814f23'
131+
expect(auth_hash['uid']).to eq '_1f6fcf6be5e13b08b1e3610e7ff59f205fbd814f23'
132132
end
133133

134134
it "should set the raw info to all attributes" do
135-
auth_hash['extra']['raw_info'].all.to_hash.should == {
135+
expect(auth_hash['extra']['raw_info'].all.to_hash).to eq(
136136
'first_name' => ['Rajiv'],
137137
'last_name' => ['Manglani'],
138138
'email' => ['user@example.com'],
139139
'company_name' => ['Example Company'],
140140
'fingerprint' => 'C1:59:74:2B:E8:0C:6C:A9:41:0F:6E:83:F6:D1:52:25:45:58:89:FB'
141-
}
141+
)
142142
end
143143
end
144144

@@ -195,12 +195,12 @@ def post_xml(xml=:example_response)
195195
end
196196

197197
it "should obey attribute statements mapping" do
198-
auth_hash[:info].should == {
198+
expect(auth_hash[:info]).to eq(
199199
'first_name' => 'Rajiv',
200200
'last_name' => 'Manglani',
201201
'email' => 'user@example.com',
202202
'name' => nil
203-
}
203+
)
204204
end
205205
end
206206
end
@@ -211,15 +211,15 @@ def post_xml(xml=:example_response)
211211
end
212212

213213
it 'should get SP metadata page' do
214-
last_response.status.should == 200
215-
last_response.header["Content-Type"].should == "application/xml"
214+
expect(last_response.status).to eq 200
215+
expect(last_response.header["Content-Type"]).to eq "application/xml"
216216
end
217217

218218
it 'should configure attributes consuming service' do
219-
last_response.body.should match /AttributeConsumingService/
220-
last_response.body.should match /first_name/
221-
last_response.body.should match /last_name/
222-
last_response.body.should match /Required attributes/
219+
expect(last_response.body).to match /AttributeConsumingService/
220+
expect(last_response.body).to match /first_name/
221+
expect(last_response.body).to match /last_name/
222+
expect(last_response.body).to match /Required attributes/
223223
end
224224
end
225225

spec/spec_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
require 'rexml/xpath'
1616
require 'base64'
1717

18+
TEST_LOGGER = Logger.new(StringIO.new)
19+
OneLogin::RubySaml::Logging.logger = TEST_LOGGER
20+
OmniAuth.config.logger = TEST_LOGGER
21+
1822
RSpec.configure do |config|
1923
config.include Rack::Test::Methods
2024
end

0 commit comments

Comments
 (0)