Skip to content

Commit a9a02d3

Browse files
committed
Merge pull request #14 from WinRb/dan/rspec-modernization
RSpect should => expect modernization
2 parents 40a0cfc + fefc52a commit a9a02d3

17 files changed

+142
-142
lines changed

Diff for: .rspec

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
--format nested
2-
--colour
3-
--drb
1+
--format documentation
2+
--color

Diff for: lib/net/ntlm.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,11 @@ def gen_keys(str)
102102
end
103103

104104
def apply_des(plain, keys)
105-
dec = OpenSSL::Cipher::DES.new
105+
dec = OpenSSL::Cipher::Cipher.new("des-cbc")
106+
dec.padding = 0
106107
keys.map {|k|
107108
dec.key = k
108-
dec.encrypt.update(plain)
109+
dec.encrypt.update(plain) + dec.final
109110
}
110111
end
111112

Diff for: rubyntlm.gemspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ Gem::Specification.new do |s|
1818
s.require_paths = ["lib"]
1919

2020
s.required_ruby_version = '>= 1.8.7'
21-
21+
2222
s.license = 'MIT'
2323

2424
s.add_development_dependency "rake"
25-
s.add_development_dependency "rspec"
25+
s.add_development_dependency "rspec", ">= 2.11"
2626
s.add_development_dependency "simplecov"
2727
end

Diff for: spec/lib/net/ntlm/encode_util_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
context '#encode_utf16le' do
66
it 'should convert an ASCII string to UTF' do
7-
Net::NTLM::EncodeUtil.encode_utf16le('Test').should == "T\x00e\x00s\x00t\x00"
7+
expect(Net::NTLM::EncodeUtil.encode_utf16le('Test')).to eq("T\x00e\x00s\x00t\x00")
88
end
99
end
1010

1111
context '#decode_utf16le' do
1212
it 'should convert a UTF string to ASCII' do
13-
Net::NTLM::EncodeUtil.decode_utf16le("T\x00e\x00s\x00t\x00").should == 'Test'
13+
expect(Net::NTLM::EncodeUtil.decode_utf16le("T\x00e\x00s\x00t\x00")).to eq('Test')
1414
end
1515
end
16-
end
16+
end

Diff for: spec/lib/net/ntlm/field_set_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
end
1919

2020
it 'should serialize all the fields' do
21-
fieldset_object.serialize.should == 'TestFoo'
21+
expect(fieldset_object.serialize).to eq('TestFoo')
2222
end
2323

2424
it 'should parse a string across the fields' do
2525
fieldset_object.parse('FooBarBaz')
26-
fieldset_object.serialize.should == 'FooBarB'
26+
expect(fieldset_object.serialize).to eq('FooBarB')
2727
end
2828

2929
it 'should return an aggregate size of all the fields' do
30-
fieldset_object.size.should == 7
30+
expect(fieldset_object.size).to eq(7)
3131
end
3232
end
33-
end
33+
end

Diff for: spec/lib/net/ntlm/field_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@
77
context 'with no size specified' do
88
let (:field_without_size) { Net::NTLM::Field.new({ :value => 'Foo', :active => true }) }
99
it 'should set size to 0 if not active' do
10-
field_without_size.size.should == 0
10+
expect(field_without_size.size).to eq(0)
1111
end
1212

1313
it 'should return 0 if active but no size specified' do
1414
field_without_size.active = true
15-
field_without_size.size.should == 0
15+
expect(field_without_size.size).to eq(0)
1616
end
1717
end
1818

1919
context 'with a size specified' do
2020
let (:field_with_size) { Net::NTLM::Field.new({ :value => 'Foo', :active => true, :size => 100 }) }
2121

2222
it 'should return the size provided in the initialize options if active' do
23-
field_with_size.size.should == 100
23+
expect(field_with_size.size).to eq(100)
2424
end
2525

2626
it 'should still return 0 if not active' do
2727
field_with_size.active = false
28-
field_with_size.size.should == 0
28+
expect(field_with_size.size).to eq(0)
2929
end
3030
end
3131

3232

3333

34-
end
34+
end

Diff for: spec/lib/net/ntlm/message/type1_spec.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@
2424

2525
it 'should deserialize' do
2626
t1 = Net::NTLM::Message.decode64(type1_packet)
27-
t1.class.should == Net::NTLM::Message::Type1
28-
t1.domain.should == ''
29-
t1.flag.should == 557575
30-
t1.padding.should == ''
31-
t1.sign.should == "NTLMSSP\0"
32-
t1.type.should == 1
33-
t1.workstation.should == ''
27+
expect(t1.class).to eq(Net::NTLM::Message::Type1)
28+
expect(t1.domain).to eq('')
29+
expect(t1.flag).to eq(557575)
30+
expect(t1.padding).to eq('')
31+
expect(t1.sign).to eq("NTLMSSP\0")
32+
expect(t1.type).to eq(1)
33+
expect(t1.workstation).to eq('')
3434
end
3535

3636
it 'should serialize' do
3737
t1 = Net::NTLM::Message::Type1.new
3838
t1.workstation = ''
39-
t1.encode64.should == type1_packet
39+
expect(t1.encode64).to eq(type1_packet)
4040
end
4141

42-
end
42+
end

Diff for: spec/lib/net/ntlm/message/type2_spec.rb

+19-19
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,24 @@
2424

2525
it 'should deserialize' do
2626
t2 = Net::NTLM::Message.decode64(type2_packet)
27-
t2.class.should == Net::NTLM::Message::Type2
28-
t2.challenge.should == 14872292244261496103
29-
t2.context.should == 0
30-
t2.flag.should == 42631685
27+
expect(t2.class).to eq(Net::NTLM::Message::Type2)
28+
expect(t2.challenge).to eq(14872292244261496103)
29+
expect(t2.context).to eq(0)
30+
expect(t2.flag).to eq(42631685)
3131
if "".respond_to?(:force_encoding)
32-
t2.padding.should == ("\x06\x01\xB1\x1D\0\0\0\x0F".force_encoding('ASCII-8BIT'))
32+
expect(t2.padding).to eq(("\x06\x01\xB1\x1D\0\0\0\x0F".force_encoding('ASCII-8BIT')))
3333
end
34-
t2.sign.should == "NTLMSSP\0"
34+
expect(t2.sign).to eq("NTLMSSP\0")
3535

3636
t2_target_info = Net::NTLM::EncodeUtil.decode_utf16le(t2.target_info)
3737
if RUBY_VERSION == "1.8.7"
38-
t2_target_info.should == "\x02\x1CVAGRANT-2008R2\x01\x1CVAGRANT-2008R2\x04\x1Cvagrant-2008R2\x03\x1Cvagrant-2008R2\a\b\e$(D+&\e(B\0\0"
38+
expect(t2_target_info).to eq("\x02\x1CVAGRANT-2008R2\x01\x1CVAGRANT-2008R2\x04\x1Cvagrant-2008R2\x03\x1Cvagrant-2008R2\a\b\e$(D+&\e(B\0\0")
3939
else
40-
t2_target_info.should == "\u0002\u001CVAGRANT-2008R2\u0001\u001CVAGRANT-2008R2\u0004\u001Cvagrant-2008R2\u0003\u001Cvagrant-2008R2\a\b፤ᐝ❴ǎ\0\0"
40+
expect(t2_target_info).to eq("\u0002\u001CVAGRANT-2008R2\u0001\u001CVAGRANT-2008R2\u0004\u001Cvagrant-2008R2\u0003\u001Cvagrant-2008R2\a\b፤ᐝ❴ǎ\0\0")
4141
end
4242

43-
Net::NTLM::EncodeUtil.decode_utf16le(t2.target_name).should == "VAGRANT-2008R2"
44-
t2.type.should == 2
43+
expect(Net::NTLM::EncodeUtil.decode_utf16le(t2.target_name)).to eq("VAGRANT-2008R2")
44+
expect(t2.type).to eq(2)
4545
end
4646

4747
it 'should serialize' do
@@ -60,7 +60,7 @@
6060
t2.enable(:target_info)
6161
t2.enable(:padding)
6262

63-
t2.encode64.should == type2_packet
63+
expect(t2.encode64).to eq(type2_packet)
6464
end
6565

6666
it 'should generate a type 3 response' do
@@ -72,17 +72,17 @@
7272
type3_known.enable(:flag)
7373

7474
t3 = t2.response({:user => 'vagrant', :password => 'vagrant', :domain => ''}, {:ntlmv2 => true, :workstation => 'kobe.local'})
75-
t3.domain.should == type3_known.domain
76-
t3.flag.should == type3_known.flag
77-
t3.sign.should == "NTLMSSP\0"
78-
t3.workstation.should == "k\0o\0b\0e\0.\0l\0o\0c\0a\0l\0"
79-
t3.user.should == "v\0a\0g\0r\0a\0n\0t\0"
80-
t3.session_key.should == ''
75+
expect(t3.domain).to eq(type3_known.domain)
76+
expect(t3.flag).to eq(type3_known.flag)
77+
expect(t3.sign).to eq("NTLMSSP\0")
78+
expect(t3.workstation).to eq("k\0o\0b\0e\0.\0l\0o\0c\0a\0l\0")
79+
expect(t3.user).to eq("v\0a\0g\0r\0a\0n\0t\0")
80+
expect(t3.session_key).to eq('')
8181
end
8282

8383
it 'should upcase domain when provided' do
8484
t2 = Net::NTLM::Message.decode64(type2_packet)
8585
t3 = t2.response({:user => 'vagrant', :password => 'vagrant', :domain => 'domain'}, {:ntlmv2 => true, :workstation => 'kobe.local'})
86-
t3.domain.should == "D\0O\0M\0A\0I\0N\0"
86+
expect(t3.domain).to eq("D\0O\0M\0A\0I\0N\0")
8787
end
88-
end
88+
end

Diff for: spec/lib/net/ntlm/message/type3_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
it_behaves_like 'a fieldset', fields
1818
it_behaves_like 'a message', flags
1919

20-
end
20+
end

Diff for: spec/lib/net/ntlm/security_buffer_spec.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,26 @@
2424
domain_security_buffer.value = 'DOMAIN1'
2525
end
2626
it 'should change the value' do
27-
domain_security_buffer.value.should == 'DOMAIN1'
27+
expect(domain_security_buffer.value).to eq('DOMAIN1')
2828
end
2929

3030
it 'should adjust the length field to the size of the new value' do
31-
domain_security_buffer.length.should == 7
31+
expect(domain_security_buffer.length).to eq(7)
3232
end
3333

3434
it 'should adjust the allocated field to the size of the new value' do
35-
domain_security_buffer.allocated.should == 7
35+
expect(domain_security_buffer.allocated).to eq(7)
3636
end
3737
end
3838

3939
context '#data_size' do
4040
it 'should return the size of the value if active' do
41-
domain_security_buffer.data_size.should == 11
41+
expect(domain_security_buffer.data_size).to eq(11)
4242
end
4343

4444
it 'should return 0 if inactive' do
4545
domain_security_buffer.active = false
46-
domain_security_buffer.data_size.should == 0
46+
expect(domain_security_buffer.data_size).to eq(0)
4747
end
4848
end
4949

@@ -56,9 +56,9 @@
5656
# The offset that the actual value begins at is also 8
5757
offset = "\x08\x00\x00\x00"
5858
string_to_parse = "#{length}#{allocated}#{offset}FooBarBaz"
59-
domain_security_buffer.parse(string_to_parse).should == 8
60-
domain_security_buffer.value.should == 'FooBarBa'
59+
expect(domain_security_buffer.parse(string_to_parse)).to eq(8)
60+
expect(domain_security_buffer.value).to eq('FooBarBa')
6161
end
6262

6363
end
64-
end
64+
end

Diff for: spec/lib/net/ntlm/string_spec.rb

+14-14
Original file line numberDiff line numberDiff line change
@@ -22,51 +22,51 @@
2222

2323
context '#serialize' do
2424
it 'should return the value when active' do
25-
active.serialize.should == 'Test'
25+
expect(active.serialize).to eq('Test')
2626
end
2727

2828
it 'should return an empty string when inactive' do
29-
inactive.serialize.should == ''
29+
expect(inactive.serialize).to eq('')
3030
end
3131

3232
it 'should coerce non-string values into strings' do
3333
active.value = 15
34-
active.serialize.should == '15'
34+
expect(active.serialize).to eq('15')
3535
end
3636

3737
it 'should return empty string on a nil' do
3838
active.value = nil
39-
active.serialize.should == ''
39+
expect(active.serialize).to eq('')
4040
end
4141
end
4242

4343
context '#value=' do
4444
it 'should set active to false if it empty' do
4545
active.value = ''
46-
active.active.should == false
46+
expect(active.active).to eq(false)
4747
end
4848

4949
it 'should adjust the size based on the value set' do
50-
active.size.should == 4
50+
expect(active.size).to eq(4)
5151
active.value = 'Foobar'
52-
active.size.should == 6
52+
expect(active.size).to eq(6)
5353
end
5454
end
5555

5656
context '#parse' do
5757
it 'should read in a string of the proper size' do
58-
active.parse('tseT').should == 4
59-
active.value.should == 'tseT'
58+
expect(active.parse('tseT')).to eq(4)
59+
expect(active.value).to eq('tseT')
6060
end
6161

6262
it 'should not read in a string that is too small' do
63-
active.parse('B').should == 0
64-
active.value.should == 'Test'
63+
expect(active.parse('B')).to eq(0)
64+
expect(active.value).to eq('Test')
6565
end
6666

6767
it 'should be able to read from an offset and only for the given size' do
68-
active.parse('FooBarBaz',3).should == 4
69-
active.value.should == 'BarB'
68+
expect(active.parse('FooBarBaz',3)).to eq(4)
69+
expect(active.value).to eq('BarB')
7070
end
7171
end
72-
end
72+
end

Diff for: spec/lib/net/ntlm/version_spec.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
describe Net::NTLM::VERSION do
44

55
it 'should contain an integer value for Major Version' do
6-
Net::NTLM::VERSION::MAJOR.should be_an Integer
6+
expect(Net::NTLM::VERSION::MAJOR).to be_an Integer
77
end
88

99
it 'should contain an integer value for Minor Version' do
10-
Net::NTLM::VERSION::MINOR.should be_an Integer
10+
expect(Net::NTLM::VERSION::MINOR).to be_an Integer
1111
end
1212

1313
it 'should contain an integer value for Patch Version' do
14-
Net::NTLM::VERSION::TINY.should be_an Integer
14+
expect(Net::NTLM::VERSION::TINY).to be_an Integer
1515
end
1616

1717
it 'should contain an aggregate version string' do
@@ -20,7 +20,7 @@
2020
Net::NTLM::VERSION::MINOR,
2121
Net::NTLM::VERSION::TINY
2222
].join('.')
23-
Net::NTLM::VERSION::STRING.should be_a String
24-
Net::NTLM::VERSION::STRING.should == string
23+
expect(Net::NTLM::VERSION::STRING).to be_a String
24+
expect(Net::NTLM::VERSION::STRING).to eq(string)
2525
end
26-
end
26+
end

0 commit comments

Comments
 (0)