spec/luhnacy_spec.rb in luhnacy-0.2.1 vs spec/luhnacy_spec.rb in luhnacy-0.2.2
- old
+ new
@@ -1,29 +1,29 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Luhnacy" do
it "should be able to identify if a number satisfies Luhn" do
valid_number = '49927398716'
- Luhnacy.valid?(valid_number).should be_true
+ Luhnacy.valid?(valid_number).should be_truthy
end
it "should be able to identify if a number does not satisfy Luhn" do
invalid_number = '49927398715'
- Luhnacy.valid?(invalid_number).should be_false
+ Luhnacy.valid?(invalid_number).should be_falsey
end
it "should return a string of digits that satisfies Luhn" do
string_size = 5
candidate = Luhnacy.generate(string_size)
candidate.should match /^\d{#{string_size}}$/
- Luhnacy.valid?(candidate).should be_true
+ Luhnacy.valid?(candidate).should be_truthy
end
it "should return a string of digits that does not satisfy Luhn" do
string_size = 5
candidate = Luhnacy.generate(string_size, :invalid => true)
- Luhnacy.valid?(candidate).should be_false
+ Luhnacy.valid?(candidate).should be_falsey
end
it "should return a string that satisfies luhn and includes a given prefix" do
prefix = '12345'
string_size = 15
@@ -38,33 +38,33 @@
end
context "Named generators and validators" do
it "should validate a correct number" do
number = '5354334446769063'
- Luhnacy.mastercard?(number).should be_true
+ Luhnacy.mastercard?(number).should be_truthy
end
it "should not validate a number if it does not satisfy Luhn" do
number = '5354334446769064'
- Luhnacy.mastercard?(number).should be_false
+ Luhnacy.mastercard?(number).should be_falsey
end
it "should not validate a number if it does not have the correct prefix" do
number = Luhnacy.generate(16, :prefix => '49')
- Luhnacy.mastercard?(number).should be_false
+ Luhnacy.mastercard?(number).should be_falsey
end
it "should not validate a number if it does not have the correct length" do
number = Luhnacy.generate(12, :prefix => '52')
- Luhnacy.mastercard?(number).should be_false
+ Luhnacy.mastercard?(number).should be_falsey
end
it "should generate a valid number" do
- Luhnacy.mastercard?(Luhnacy.mastercard).should be_true
+ Luhnacy.mastercard?(Luhnacy.mastercard).should be_truthy
end
it "should generate an invalid number" do
- Luhnacy.mastercard?(Luhnacy.mastercard(:invalid => true)).should be_false
+ Luhnacy.mastercard?(Luhnacy.mastercard(:invalid => true)).should be_falsey
end
it "should raise an error if there is no matcher or validator with a given name" do
lambda { Luhnacy.superawesomecard?('123') }.should raise_error NoMethodError
end