copyright 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{copyright}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Takaaki Kato"]
@@ -3,8 +3,6 @@
3
3
  # Adds a method for copyright period
4
4
  # @author Takaaki Kato <takaaki.kato@gmail.com>
5
5
  module CopyrightHelper
6
- require 'date'
7
-
8
6
  # Returns copyright period in years
9
7
  # @example When the argument is the year of now
10
8
  # copyright_years(2009) #=> "2009"
@@ -13,11 +11,11 @@ module CopyrightHelper
13
11
  # @param [#is_a?(Integer)]
14
12
  def copyright_years(since)
15
13
  raise ArgumentError, "Argument should be a number" unless since.is_a?(Integer)
16
- raise ArgumentError, "since should not be a future" if since > Date.today.year
17
- if since == Date.today.year
14
+ raise ArgumentError, "since should not be a future" if since > Time.new.year
15
+ if since == Time.new.year
18
16
  "#{since}"
19
- else
20
- "#{since}-#{Date.today.year}"
17
+ else
18
+ "#{since}-#{Time.new.year}"
21
19
  end
22
20
  end
23
21
  end
@@ -1,33 +1,36 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
- require 'test_helper'
4
+ # require './test_helper.rb'
5
+
6
+ require File.join(File.dirname(__FILE__), ["test_helper"])
5
7
  include CopyrightHelper
6
8
 
7
9
  class CopyrightYearTest < Test::Unit::TestCase
10
+ context "#copyright_years()" do
11
+ setup do
12
+ @this_year = Time.stubs(:new).returns(Time.local(2010))
13
+ @this_year.stubs(:year).returns(2010)
14
+ end
8
15
 
9
- def setup
10
- @today = Date.stubs(:today).returns(Date.civil(2009))
11
- @today.stubs(:year).returns(2009)
12
- end
13
-
14
- should "raise when an argument is not a number" do
15
- assert_raise(ArgumentError) { copyright_years() }
16
- assert_raise(ArgumentError) { copyright_years("123") }
17
- assert_nothing_raised { copyright_years(2004) }
18
- assert_nothing_raised { copyright_years(2009) }
19
- end
16
+ should "raise when an argument is not a number" do
17
+ assert_raise(ArgumentError) { copyright_years() }
18
+ assert_raise(ArgumentError) { copyright_years("123") }
19
+ assert_nothing_raised { copyright_years(2004) }
20
+ assert_nothing_raised { copyright_years(2009) }
21
+ end
20
22
 
21
- should "returen the number of 'since' when the 'since' is the year of today" do
22
- assert_equal("2009", copyright_years(@today.year))
23
- end
23
+ should "returen the number of 'since' when the 'since' is the year of today" do
24
+ assert_equal("2010", copyright_years(2010))
25
+ end
24
26
 
25
- should "return 2009 - 2010 when the argument is not the year of 'since'" do
26
- years = copyright_years(2006)
27
- assert_equal("2006-2009", years)
28
- end
27
+ should "return 2009-2010 when the argument is not the year of 'since'" do
28
+ years = copyright_years(2006)
29
+ assert_equal("2006-2010", years)
30
+ end
29
31
 
30
- should "raise the argument is bigger than the this year" do
31
- assert_raise(ArgumentError) {copyright_years(2220)}
32
+ should "raise the argument is bigger than the this year" do
33
+ assert_raise(ArgumentError) {copyright_years(2220)}
34
+ end
32
35
  end
33
36
  end
@@ -5,5 +5,5 @@ require 'mocha'
5
5
 
6
6
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
7
  $LOAD_PATH.unshift(File.dirname(__FILE__))
8
- require 'copyright_helper'
8
+ require 'copyright'
9
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: copyright
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takaaki Kato