Created
June 6, 2020 02:36
-
-
Save jimytc/034440dfb3098e3edef0912bf9820954 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
source 'https://rubygems.org' | |
gem 'activesupport' | |
gem 'minitest' | |
gem 'minitest-reporters', '>= 0.5.0' | |
gem 'rr' | |
gem 'rubocop' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
class Holiday | |
def sayHello | |
if christmas?(Date.today) | |
"Merry X'mas" | |
else | |
"Today is not X'mas" | |
end | |
end | |
private | |
def christmas?(date) | |
date.day == 25 && date.month == 12 | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'minitest/autorun' | |
require 'date' | |
require_relative 'holiday' | |
class HolidayTest < Minitest::Test | |
def test_has_class_and_method | |
assert Holiday.new.sayHello | |
end | |
def test_is_christmas | |
Date.stub(Date.today, Date.new(2020, 12, 25)) do | |
assert_equal "Merry X'mas", Holiday.new.sayHello | |
end | |
end | |
def test_is_not_christmas | |
Date.stub(Date.today, Date.new(2020, 3, 3)) do | |
assert_equal "Today is not X'mas", Holiday.new.sayHello | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment