Sha256: 704b65639b197df8e6c108be74a9bd9c0379a7a96874b1c2d7d5799f21b1867d

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

# require './test_helper.rb'

require File.join(File.dirname(__FILE__), ["test_helper"])
include CopyrightHelper

class CopyrightYearTest < Test::Unit::TestCase
  context "#copyright_years()" do
    setup do
      @this_year = Time.stubs(:new).returns(Time.local(2010))
      @this_year.stubs(:year).returns(2010)
    end
  
    should "raise when an argument is not a number" do
      assert_raise(ArgumentError) { copyright_years() }
      assert_raise(ArgumentError) { copyright_years("123") }
      assert_nothing_raised { copyright_years(2004) }
      assert_nothing_raised { copyright_years(2009) }
    end
  
    should "returen the number of 'since' when the 'since' is the year of today" do
      assert_equal("2010", copyright_years(2010))
    end
  
    should "return 2009-2010 when the argument is not the year of 'since'" do
      years = copyright_years(2006)
      assert_equal("2006-2010", years)
    end
  
    should "raise the argument is bigger than the this year" do
      assert_raise(ArgumentError) {copyright_years(2220)}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
copyright-0.1.5 test/test_copyright.rb