Skip to content

Commit 0970d68

Browse files
committed
Returns true if Class LeapYear is divisible by 100 & 400
1 parent a62ec2b commit 0970d68

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

bin/leap_year.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ def initialize(year)
1010
end
1111

1212
def yes?
13-
leap = false
1413
if @year % 4 == 0
1514
leap = true
15+
elsif @year % 100 == 0 && @year % 400 == 0
16+
leap = true
17+
elsif @year % 100 == 0 && @year % 400 != 0
18+
leap = false
1619
else
1720
leap = false
1821
end

spec/leap_year_rspec.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
leap_year = LeapYear.new(1996)
1313
expected = true
1414
actual = leap_year.yes?
15-
expect(actual). to eq expected
15+
expect(actual).to eq expected
1616
end
1717

1818
it "calls a method 'yes?' and tells if it's leap year (false)" do
@@ -21,4 +21,11 @@
2121
actual = not_leap_year.yes?
2222
expect(actual).to eq expected
2323
end
24+
25+
it "Returns True if Class LeapYear is divisible by 100 & 400" do
26+
leap_year = LeapYear.new(2000)
27+
expected = true
28+
actual = leap_year.yes?
29+
expect(actual).to eq expected
30+
end
2431
end

0 commit comments

Comments
 (0)