cal 02 2012 | pbcopy
Last active
August 29, 2015 14:19
-
-
Save elizabrock/0a6149ea6ce87473fcb4 to your computer and use it in GitHub Desktop.
This file contains 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
ruby test/test_months_integration.rb --name test_basic_month_that_starts_on_sunday |
This file contains 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
#!/usr/bin/env ruby | |
month = ARGV[0] | |
year = ARGV[1] | |
puts `cal #{month} #{year}` |
This file contains 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
class Month | |
attr_reader :month, :year | |
def initialize(month, year) | |
@month = month | |
@year = year | |
end | |
def to_s | |
<<EOS | |
January #{year} | |
Su Mo Tu We Th Fr Sa | |
1 2 3 4 5 6 7 | |
8 9 10 11 12 13 14 | |
15 16 17 18 19 20 21 | |
22 23 24 25 26 27 28 | |
29 30 31 | |
EOS | |
end | |
end |
This file contains 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
require_relative 'helper' | |
require_relative '../lib/month' | |
class TestMonth < Minitest::Test | |
def test_initializing_a_month_saves_values | |
m = Month.new(05, 2015) | |
assert_equal 05, m.month | |
assert_equal 2015, m.year | |
end | |
def test_to_s_on_jan_2012 | |
m = Month.new(01, 2012) | |
expected = <<EOS | |
January 2012 | |
Su Mo Tu We Th Fr Sa | |
1 2 3 4 5 6 7 | |
8 9 10 11 12 13 14 | |
15 16 17 18 19 20 21 | |
22 23 24 25 26 27 28 | |
29 30 31 | |
EOS | |
assert_equal expected, m.to_s | |
end | |
def test_to_s_on_jan_2017 | |
m = Month.new(01, 2017) | |
expected = <<EOS | |
January 2017 | |
Su Mo Tu We Th Fr Sa | |
1 2 3 4 5 6 7 | |
8 9 10 11 12 13 14 | |
15 16 17 18 19 20 21 | |
22 23 24 25 26 27 28 | |
29 30 31 | |
EOS | |
assert_equal expected, m.to_s | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment