spec/egn/generator_spec.rb in egn-1.2.1 vs spec/egn/generator_spec.rb in egn-1.2.2

- old
+ new

@@ -41,16 +41,24 @@ expect(egn.month).to eq(6) end it "generates a new EGN with the given day" do - number = Egn::Generator.generate(day: 15) + number = Egn::Generator.generate(day: 29) egn = Egn::Egn.new(number) - expect(egn.day).to eq(15) + expect(egn.day).to eq(29) end + it "doesn't generate invalid EGN's for day 29 (in case of february)" do + Array.new(10_000) { |i| Egn.generate(day: 29) }.each do |egn| + result = Egn::Validator.validate(egn) + expect(result).to be_true, "Failed for #{egn}" + end + + end + it "generates female EGNs" do number = Egn::Generator.generate(sex: :female) egn = Egn::Egn.new(number) expect(egn.sex).to eq(:female) @@ -63,12 +71,12 @@ expect(egn.sex).to eq(:male) end it "validates the options" do - options = {year: 1960, month: 6, day: 3, sex: :male} + options = {year: 1960, month: 6, day: 3, sex: :male, region: 333} - Egn::Generator.any_instance.should_receive(:validate!).with(options) + Egn::Generator.any_instance.should_receive(:validate!) Egn::Generator.generate(options) end end