spec/pwm_spec.rb in pwm-1.2.0 vs spec/pwm_spec.rb in pwm-1.2.1

- old
+ new

@@ -1,62 +1,60 @@ require 'pwm' describe Pwm do - context 'The default set of characters' do - it 'includes all upper-case letters except I and O' do - (('A'..'Z').to_a - ['I', 'O']).each do |letter| - Pwm.characters.should include(letter) + describe 'The default set of characters' do + (('A'..'Z').to_a - ['I', 'O']).each do |letter| + it "includes #{letter}" do + expect(Pwm.characters).to include(letter) end end - it 'includes all lower-case letters except l' do - (('a'..'z').to_a - ['l']).each do |letter| - Pwm.characters.should include(letter) + (('a'..'z').to_a - ['l']).each do |letter| + it "includes #{letter}" do + expect(Pwm.characters).to include(letter) end end - it 'includes all digits 2 through 9' do - ('2'..'9').each do |letter| - Pwm.characters.should include(letter) + ('2'..'9').each do |letter| + it "includes #{letter}" do + expect(Pwm.characters).to include(letter) end end - it 'does not include I, O, l, 0, or 1' do - %w(I O l 0 1).each do |letter| - Pwm.characters.should_not include(letter) + %w(I O l 0 1).each do |letter| + it "does not include #{letter}" do + expect(Pwm.characters).not_to include(letter) end end end - context 'The password method' do + describe 'The password method' do context 'when given a length' do context 'equal to 8' do it 'generates a password of that length' do - Pwm.password(8).length.should == 8 + expect(Pwm.password(8).length).to eq(8) end end context 'greater than 8' do it 'generates a password of that length' do - Pwm.password(9).length.should == 9 + expect(Pwm.password(9).length).to eq(9) end end context 'less than 8' do - it 'does not generate a password' do + it 'raises Pwm::TooShortException' do expect { Pwm.password(7) }.to raise_error(Pwm::TooShortException) end end end context 'when not given a length' do it 'generates a 16-character password' do - Pwm.password.length.should == 16 + expect(Pwm.password.length).to eq(16) end end - context 'generates passwords containing' do - it 'at least one upper-case letter' do - Pwm.password.should match(/[A-Z]/) - end - it 'at least one lower-case letter' do - Pwm.password.should match(/[a-z]/) - end - it 'at least one number' do - Pwm.password.should match(/[2-9]/) - end + it 'generates passwords containing at least one upper-case letter' do + expect(Pwm.password).to match(/[A-Z]/) + end + it 'generates passwords containing at least one lower-case letter' do + expect(Pwm.password).to match(/[a-z]/) + end + it 'generates passwords containing at least one number' do + expect(Pwm.password).to match(/[2-9]/) end end end