Skip to content

Instantly share code, notes, and snippets.

@elizabrock
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elizabrock/0a6149ea6ce87473fcb4 to your computer and use it in GitHub Desktop.
Save elizabrock/0a6149ea6ce87473fcb4 to your computer and use it in GitHub Desktop.
cal 02 2012 | pbcopy
ruby test/test_months_integration.rb --name test_basic_month_that_starts_on_sunday
#!/usr/bin/env ruby
month = ARGV[0]
year = ARGV[1]
puts `cal #{month} #{year}`
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
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