require 'minitest/autorun'
require 'time'

class TestCheersIntegration < Minitest::Test

  def test_help_message
    output = `./cheers`
    expected = <<EOS
I'd cheer for you, if only I knew who you were :(
Try again with `./cheers.rb [Name] [MM/DD Birthday]
EOS
   assert_equal expected, output
  end

  def test_two_valid_arguments
    output = `./cheers Abby 08/25`
    expected = <<EOS
Give me an... A!
Give me a... B!
Give me a... B!
Give me a... Y!
Abby's just GRAND!
Awesome! Your birthday is in 125 days! Happy Birthday in advance!
EOS
  assert_equal expected, output
  end

  def test_one_argument_valid_name
    output = `./cheers Abby`
    expected =  <<EOS
Give me an... A!
Give me a... B!
Give me a... B!
Give me a... Y!
Abby's just GRAND!
Try again with `./cheers.rb [Name] [MM/DD Birthday]
EOS
    assert_equal expected, output
  end

  def test_one_argument_invalid_name
    output = `./cheers 0320`
    expected = <<EOS
I'd cheer for you, if only I knew who you were :(
Try again with `./cheers.rb [Name] [MM/DD Birthday]
EOS
    assert_equal expected, output
  end

  def test_one_argument_valid_birthday
    output = `./cheers 03/11`
    expected = <<EOS
I'd cheer for you, if only I knew who you were :(
Try again with `./cheers.rb [Name] [MM/DD Birthday]
EOS
    assert_equal expected, output
  end

  def test_two_arguments_invalid_birthday
    output = `./cheers Abby 25/08`
    expected = <<EOS
Give me an... A!
Give me a... B!
Give me a... B!
Give me a... Y!
Abby's just GRAND!
Try again with `./cheers.rb [Name] [MM/DD Birthday]
EOS
    assert_equal expected, output
  end

  def test_two_arguments_invalid_name
    output = `./cheers 0403 04/02`
    expected = <<EOS
I'd cheer for you, if only I knew who you were :(
Try again with `./cheers.rb [Name] [MM/DD Birthday]
EOS
    assert_equal expected, output
  end

  def test_hyphen_name
    output = `./cheers Mary-Ann`
    expected = <<EOS
Give me an... M!
Give me an... A!
Give me an... R!
Give me a... Y!
Give me an... A!
Give me an... N!
Give me an... N!
Mary-Ann's just GRAND!
Try again with `./cheers.rb [Name] [MM/DD Birthday]
EOS
    assert_equal expected, output
  end

  def test_one_argument_spaced_name
    output = `./cheers "Mary Jane"`
    expected =<<EOS
Give me an... M!
Give me an... A!
Give me an... R!
Give me a... Y!
Give me a... J!
Give me an... A!
Give me an... N!
Give me an... E!
Mary Jane's just GRAND!
Try again with `./cheers.rb [Name] [MM/DD Birthday]
EOS
    assert_equal expected, output
  end

  def test_only_white_space_in_name
    output = `./cheers " "`
    expected = <<EOS
I'd cheer for you, if only I knew who you were :(
Try again with `./cheers.rb [Name] [MM/DD Birthday]
EOS
    assert_equal expected, output
  end

  def test_no_characters_in_name
    output = `./cheers ""`
    expected = <<EOS
I'd cheer for you, if only I knew who you were :(
Try again with `./cheers.rb [Name] [MM/DD Birthday]
EOS
    assert_equal expected, output
  end

  def test_nonword_characters_name
    output = `./cheers %^*@`
    expected = <<EOS
I'd cheer for you, if only I knew who you were :(
Try again with `./cheers.rb [Name] [MM/DD Birthday]
EOS
    assert_equal expected, output
  end

  def test_if_year_is_in_date
    output = `./cheers Abby 05/11/1988`
    expected = <<EOS
Give me an... A!
Give me a... B!
Give me a... B!
Give me a... Y!
Abby's just GRAND!
Try again with `./cheers.rb [Name] [MM/DD Birthday]
EOS
    assert_equal expected, output
  end

  def test_if_birthday_already_happened
    output = `./cheers Abby 04/21`
    expected = <<EOS
Give me an... A!
Give me a... B!
Give me a... B!
Give me a... Y!
Abby's just GRAND!
Awesome! Your birthday is in 364 days! Happy Birthday in advance!
EOS
    assert_equal expected, output
  end



end


