Skip to content

Commit

Permalink
RSpect should => expect modernization
Browse files Browse the repository at this point in the history
  • Loading branch information
zenchild committed Dec 5, 2014
1 parent fd51f60 commit a4607f4
Show file tree
Hide file tree
Showing 15 changed files with 137 additions and 138 deletions.
5 changes: 2 additions & 3 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
--format nested
--colour
--drb
--format documentation
--color
6 changes: 3 additions & 3 deletions spec/lib/net/ntlm/encode_util_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

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

context '#decode_utf16le' do
it 'should convert a UTF string to ASCII' do
Net::NTLM::EncodeUtil.decode_utf16le("T\x00e\x00s\x00t\x00").should == 'Test'
expect(Net::NTLM::EncodeUtil.decode_utf16le("T\x00e\x00s\x00t\x00")).to eq('Test')
end
end
end
end
8 changes: 4 additions & 4 deletions spec/lib/net/ntlm/field_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
end

it 'should serialize all the fields' do
fieldset_object.serialize.should == 'TestFoo'
expect(fieldset_object.serialize).to eq('TestFoo')
end

it 'should parse a string across the fields' do
fieldset_object.parse('FooBarBaz')
fieldset_object.serialize.should == 'FooBarB'
expect(fieldset_object.serialize).to eq('FooBarB')
end

it 'should return an aggregate size of all the fields' do
fieldset_object.size.should == 7
expect(fieldset_object.size).to eq(7)
end
end
end
end
10 changes: 5 additions & 5 deletions spec/lib/net/ntlm/field_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@
context 'with no size specified' do
let (:field_without_size) { Net::NTLM::Field.new({ :value => 'Foo', :active => true }) }
it 'should set size to 0 if not active' do
field_without_size.size.should == 0
expect(field_without_size.size).to eq(0)
end

it 'should return 0 if active but no size specified' do
field_without_size.active = true
field_without_size.size.should == 0
expect(field_without_size.size).to eq(0)
end
end

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

it 'should return the size provided in the initialize options if active' do
field_with_size.size.should == 100
expect(field_with_size.size).to eq(100)
end

it 'should still return 0 if not active' do
field_with_size.active = false
field_with_size.size.should == 0
expect(field_with_size.size).to eq(0)
end
end



end
end
18 changes: 9 additions & 9 deletions spec/lib/net/ntlm/message/type1_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@

it 'should deserialize' do
t1 = Net::NTLM::Message.decode64(type1_packet)
t1.class.should == Net::NTLM::Message::Type1
t1.domain.should == ''
t1.flag.should == 557575
t1.padding.should == ''
t1.sign.should == "NTLMSSP\0"
t1.type.should == 1
t1.workstation.should == ''
expect(t1.class).to eq(Net::NTLM::Message::Type1)
expect(t1.domain).to eq('')
expect(t1.flag).to eq(557575)
expect(t1.padding).to eq('')
expect(t1.sign).to eq("NTLMSSP\0")
expect(t1.type).to eq(1)
expect(t1.workstation).to eq('')
end

it 'should serialize' do
t1 = Net::NTLM::Message::Type1.new
t1.workstation = ''
t1.encode64.should == type1_packet
expect(t1.encode64).to eq(type1_packet)
end

end
end
38 changes: 19 additions & 19 deletions spec/lib/net/ntlm/message/type2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@

it 'should deserialize' do
t2 = Net::NTLM::Message.decode64(type2_packet)
t2.class.should == Net::NTLM::Message::Type2
t2.challenge.should == 14872292244261496103
t2.context.should == 0
t2.flag.should == 42631685
expect(t2.class).to eq(Net::NTLM::Message::Type2)
expect(t2.challenge).to eq(14872292244261496103)
expect(t2.context).to eq(0)
expect(t2.flag).to eq(42631685)
if "".respond_to?(:force_encoding)
t2.padding.should == ("\x06\x01\xB1\x1D\0\0\0\x0F".force_encoding('ASCII-8BIT'))
expect(t2.padding).to eq(("\x06\x01\xB1\x1D\0\0\0\x0F".force_encoding('ASCII-8BIT')))
end
t2.sign.should == "NTLMSSP\0"
expect(t2.sign).to eq("NTLMSSP\0")

t2_target_info = Net::NTLM::EncodeUtil.decode_utf16le(t2.target_info)
if RUBY_VERSION == "1.8.7"
t2_target_info.should == "\x02\x1CVAGRANT-2008R2\x01\x1CVAGRANT-2008R2\x04\x1Cvagrant-2008R2\x03\x1Cvagrant-2008R2\a\b\e$(D+&\e(B\0\0"
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")
else
t2_target_info.should == "\u0002\u001CVAGRANT-2008R2\u0001\u001CVAGRANT-2008R2\u0004\u001Cvagrant-2008R2\u0003\u001Cvagrant-2008R2\a\b፤ᐝ❴ǎ\0\0"
expect(t2_target_info).to eq("\u0002\u001CVAGRANT-2008R2\u0001\u001CVAGRANT-2008R2\u0004\u001Cvagrant-2008R2\u0003\u001Cvagrant-2008R2\a\b፤ᐝ❴ǎ\0\0")
end

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

it 'should serialize' do
Expand All @@ -60,7 +60,7 @@
t2.enable(:target_info)
t2.enable(:padding)

t2.encode64.should == type2_packet
expect(t2.encode64).to eq(type2_packet)
end

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

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

it 'should upcase domain when provided' do
t2 = Net::NTLM::Message.decode64(type2_packet)
t3 = t2.response({:user => 'vagrant', :password => 'vagrant', :domain => 'domain'}, {:ntlmv2 => true, :workstation => 'kobe.local'})
t3.domain.should == "D\0O\0M\0A\0I\0N\0"
expect(t3.domain).to eq("D\0O\0M\0A\0I\0N\0")
end
end
end
2 changes: 1 addition & 1 deletion spec/lib/net/ntlm/message/type3_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
it_behaves_like 'a fieldset', fields
it_behaves_like 'a message', flags

end
end
16 changes: 8 additions & 8 deletions spec/lib/net/ntlm/security_buffer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@
domain_security_buffer.value = 'DOMAIN1'
end
it 'should change the value' do
domain_security_buffer.value.should == 'DOMAIN1'
expect(domain_security_buffer.value).to eq('DOMAIN1')
end

it 'should adjust the length field to the size of the new value' do
domain_security_buffer.length.should == 7
expect(domain_security_buffer.length).to eq(7)
end

it 'should adjust the allocated field to the size of the new value' do
domain_security_buffer.allocated.should == 7
expect(domain_security_buffer.allocated).to eq(7)
end
end

context '#data_size' do
it 'should return the size of the value if active' do
domain_security_buffer.data_size.should == 11
expect(domain_security_buffer.data_size).to eq(11)
end

it 'should return 0 if inactive' do
domain_security_buffer.active = false
domain_security_buffer.data_size.should == 0
expect(domain_security_buffer.data_size).to eq(0)
end
end

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

end
end
end
28 changes: 14 additions & 14 deletions spec/lib/net/ntlm/string_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,51 +22,51 @@

context '#serialize' do
it 'should return the value when active' do
active.serialize.should == 'Test'
expect(active.serialize).to eq('Test')
end

it 'should return an empty string when inactive' do
inactive.serialize.should == ''
expect(inactive.serialize).to eq('')
end

it 'should coerce non-string values into strings' do
active.value = 15
active.serialize.should == '15'
expect(active.serialize).to eq('15')
end

it 'should return empty string on a nil' do
active.value = nil
active.serialize.should == ''
expect(active.serialize).to eq('')
end
end

context '#value=' do
it 'should set active to false if it empty' do
active.value = ''
active.active.should == false
expect(active.active).to eq(false)
end

it 'should adjust the size based on the value set' do
active.size.should == 4
expect(active.size).to eq(4)
active.value = 'Foobar'
active.size.should == 6
expect(active.size).to eq(6)
end
end

context '#parse' do
it 'should read in a string of the proper size' do
active.parse('tseT').should == 4
active.value.should == 'tseT'
expect(active.parse('tseT')).to eq(4)
expect(active.value).to eq('tseT')
end

it 'should not read in a string that is too small' do
active.parse('B').should == 0
active.value.should == 'Test'
expect(active.parse('B')).to eq(0)
expect(active.value).to eq('Test')
end

it 'should be able to read from an offset and only for the given size' do
active.parse('FooBarBaz',3).should == 4
active.value.should == 'BarB'
expect(active.parse('FooBarBaz',3)).to eq(4)
expect(active.value).to eq('BarB')
end
end
end
end
12 changes: 6 additions & 6 deletions spec/lib/net/ntlm/version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
describe Net::NTLM::VERSION do

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

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

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

it 'should contain an aggregate version string' do
Expand All @@ -20,7 +20,7 @@
Net::NTLM::VERSION::MINOR,
Net::NTLM::VERSION::TINY
].join('.')
Net::NTLM::VERSION::STRING.should be_a String
Net::NTLM::VERSION::STRING.should == string
expect(Net::NTLM::VERSION::STRING).to be_a String
expect(Net::NTLM::VERSION::STRING).to eq(string)
end
end
end
Loading

0 comments on commit a4607f4

Please sign in to comment.